chore(format): update coding style
This commit is contained in:
parent
5609d9e9ce
commit
2b4e03eed6
17 changed files with 39 additions and 40 deletions
|
@ -513,7 +513,7 @@ func (a *API) handleExport(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
func filterOrphanBlocks(blocks []model.Block) (ret []model.Block) {
|
||||
queue := make([]model.Block, 0)
|
||||
var childrenOfBlockWithID = make(map[string]*[]model.Block)
|
||||
childrenOfBlockWithID := make(map[string]*[]model.Block)
|
||||
|
||||
// Build the trees from nodes
|
||||
for _, block := range blocks {
|
||||
|
|
|
@ -16,7 +16,7 @@ func (a *App) GetSession(token string) (*model.Session, error) {
|
|||
}
|
||||
|
||||
// IsValidReadToken validates the read token for a block
|
||||
func (a *App) IsValidReadToken(blockID string, readToken string) (bool, error) {
|
||||
func (a *App) IsValidReadToken(blockID, readToken string) (bool, error) {
|
||||
return a.auth.IsValidReadToken(blockID, readToken)
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ func (a *App) GetUser(ID string) (*model.User, error) {
|
|||
}
|
||||
|
||||
// Login create a new user session if the authentication data is valid
|
||||
func (a *App) Login(username string, email string, password string, mfaToken string) (string, error) {
|
||||
func (a *App) Login(username, email, password, mfaToken string) (string, error) {
|
||||
var user *model.User
|
||||
if username != "" {
|
||||
var err error
|
||||
|
@ -99,7 +99,7 @@ func (a *App) Login(username string, email string, password string, mfaToken str
|
|||
}
|
||||
|
||||
// RegisterUser create a new user if the provided data is valid
|
||||
func (a *App) RegisterUser(username string, email string, password string) error {
|
||||
func (a *App) RegisterUser(username, email, password string) error {
|
||||
var user *model.User
|
||||
if username != "" {
|
||||
var err error
|
||||
|
@ -144,7 +144,7 @@ func (a *App) RegisterUser(username string, email string, password string) error
|
|||
return nil
|
||||
}
|
||||
|
||||
func (a *App) UpdateUserPassword(username string, password string) error {
|
||||
func (a *App) UpdateUserPassword(username, password string) error {
|
||||
err := a.store.UpdateUserPassword(username, auth.HashPassword(password))
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -153,7 +153,7 @@ func (a *App) UpdateUserPassword(username string, password string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (a *App) ChangePassword(userID string, oldPassword string, newPassword string) error {
|
||||
func (a *App) ChangePassword(userID, oldPassword, newPassword string) error {
|
||||
var user *model.User
|
||||
if userID != "" {
|
||||
var err error
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"github.com/mattermost/focalboard/server/model"
|
||||
)
|
||||
|
||||
func (a *App) GetBlocks(parentID string, blockType string) ([]model.Block, error) {
|
||||
func (a *App) GetBlocks(parentID, blockType string) ([]model.Block, error) {
|
||||
if len(blockType) > 0 && len(parentID) > 0 {
|
||||
return a.store.GetBlocksWithParentAndType(parentID, blockType)
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ func (a *App) GetAllBlocks() ([]model.Block, error) {
|
|||
return a.store.GetAllBlocks()
|
||||
}
|
||||
|
||||
func (a *App) DeleteBlock(blockID string, modifiedBy string) error {
|
||||
func (a *App) DeleteBlock(blockID, modifiedBy string) error {
|
||||
blockIDsToNotify := []string{blockID}
|
||||
parentID, err := a.GetParentID(blockID)
|
||||
if err != nil {
|
||||
|
|
|
@ -38,7 +38,7 @@ func (a *Auth) GetSession(token string) (*model.Session, error) {
|
|||
}
|
||||
|
||||
// IsValidReadToken validates the read token for a block
|
||||
func (a *Auth) IsValidReadToken(blockID string, readToken string) (bool, error) {
|
||||
func (a *Auth) IsValidReadToken(blockID, readToken string) (bool, error) {
|
||||
rootID, err := a.store.GetRootID(blockID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
|
|
@ -63,7 +63,7 @@ type Client struct {
|
|||
HttpHeader map[string]string
|
||||
}
|
||||
|
||||
func NewClient(url string, sessionToken string) *Client {
|
||||
func NewClient(url, sessionToken string) *Client {
|
||||
url = strings.TrimRight(url, "/")
|
||||
headers := map[string]string{
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
|
@ -72,11 +72,11 @@ func NewClient(url string, sessionToken string) *Client {
|
|||
return &Client{url, url + API_URL_SUFFIX, &http.Client{}, headers}
|
||||
}
|
||||
|
||||
func (c *Client) DoApiGet(url string, etag string) (*http.Response, error) {
|
||||
func (c *Client) DoApiGet(url, etag string) (*http.Response, error) {
|
||||
return c.DoApiRequest(http.MethodGet, c.ApiUrl+url, "", etag)
|
||||
}
|
||||
|
||||
func (c *Client) DoApiPost(url string, data string) (*http.Response, error) {
|
||||
func (c *Client) DoApiPost(url, data string) (*http.Response, error) {
|
||||
return c.DoApiRequest(http.MethodPost, c.ApiUrl+url, data, "")
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ func (c *Client) doApiPostBytes(url string, data []byte) (*http.Response, error)
|
|||
return c.doApiRequestBytes(http.MethodPost, c.ApiUrl+url, data, "")
|
||||
}
|
||||
|
||||
func (c *Client) DoApiPut(url string, data string) (*http.Response, error) {
|
||||
func (c *Client) DoApiPut(url, data string) (*http.Response, error) {
|
||||
return c.DoApiRequest(http.MethodPut, c.ApiUrl+url, data, "")
|
||||
}
|
||||
|
||||
|
|
|
@ -179,7 +179,6 @@ func TestDeleteBlock(t *testing.T) {
|
|||
blockIDs[i] = b.ID
|
||||
}
|
||||
require.Contains(t, blockIDs, blockID)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Delete a block", func(t *testing.T) {
|
||||
|
|
|
@ -159,7 +159,7 @@ func main() {
|
|||
|
||||
// StartServer starts the server
|
||||
//export StartServer
|
||||
func StartServer(webPath *C.char, port int, singleUserToken *C.char, dbConfigString *C.char) {
|
||||
func StartServer(webPath *C.char, port int, singleUserToken, dbConfigString *C.char) {
|
||||
startServer(
|
||||
C.GoString(webPath),
|
||||
port,
|
||||
|
@ -174,7 +174,7 @@ func StopServer() {
|
|||
stopServer()
|
||||
}
|
||||
|
||||
func startServer(webPath string, port int, singleUserToken string, dbConfigString string) {
|
||||
func startServer(webPath string, port int, singleUserToken, dbConfigString string) {
|
||||
logInfo()
|
||||
|
||||
if pServer != nil {
|
||||
|
|
|
@ -9,8 +9,10 @@ var versions = []string{
|
|||
"0.5.0",
|
||||
}
|
||||
|
||||
var CurrentVersion string = versions[0]
|
||||
var BuildNumber string
|
||||
var BuildDate string
|
||||
var BuildHash string
|
||||
var Edition string
|
||||
var (
|
||||
CurrentVersion string = versions[0]
|
||||
BuildNumber string
|
||||
BuildDate string
|
||||
BuildHash string
|
||||
Edition string
|
||||
)
|
||||
|
|
|
@ -2,9 +2,7 @@ package auth
|
|||
|
||||
import "regexp"
|
||||
|
||||
var (
|
||||
emailRegex = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
|
||||
)
|
||||
var emailRegex = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
|
||||
|
||||
// IsEmailValid checks if the email provided passes the required structure and length.
|
||||
func IsEmailValid(e string) bool {
|
||||
|
|
|
@ -38,7 +38,7 @@ func HashPassword(password string) string {
|
|||
}
|
||||
|
||||
// ComparePassword compares the hash
|
||||
func ComparePassword(hash string, password string) bool {
|
||||
func ComparePassword(hash, password string) bool {
|
||||
if len(password) == 0 || len(hash) == 0 {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ func (s *SQLStore) latestsBlocksSubquery() sq.SelectBuilder {
|
|||
Where(sq.Eq{"delete_at": 0})
|
||||
}
|
||||
|
||||
func (s *SQLStore) GetBlocksWithParentAndType(parentID string, blockType string) ([]model.Block, error) {
|
||||
func (s *SQLStore) GetBlocksWithParentAndType(parentID, blockType string) ([]model.Block, error) {
|
||||
query := s.getQueryBuilder().
|
||||
Select(
|
||||
"id",
|
||||
|
@ -218,7 +218,7 @@ func (s *SQLStore) GetAllBlocks() ([]model.Block, error) {
|
|||
func blocksFromRows(rows *sql.Rows) ([]model.Block, error) {
|
||||
defer rows.Close()
|
||||
|
||||
var results = []model.Block{}
|
||||
results := []model.Block{}
|
||||
|
||||
for rows.Next() {
|
||||
var block model.Block
|
||||
|
@ -341,7 +341,7 @@ func (s *SQLStore) InsertBlock(block model.Block) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *SQLStore) DeleteBlock(blockID string, modifiedBy string) error {
|
||||
func (s *SQLStore) DeleteBlock(blockID, modifiedBy string) error {
|
||||
now := time.Now().Unix()
|
||||
query := s.getQueryBuilder().Insert("blocks").
|
||||
Columns(
|
||||
|
|
|
@ -26,7 +26,7 @@ func (s *SQLStore) GetSystemSettings() (map[string]string, error) {
|
|||
return results, nil
|
||||
}
|
||||
|
||||
func (s *SQLStore) SetSystemSetting(id string, value string) error {
|
||||
func (s *SQLStore) SetSystemSetting(id, value string) error {
|
||||
query := s.getQueryBuilder().Insert("system_settings").Columns("id", "value").Values(id, value)
|
||||
|
||||
_, err := query.Exec()
|
||||
|
|
|
@ -109,7 +109,7 @@ func (s *SQLStore) UpdateUser(user *model.User) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *SQLStore) UpdateUserPassword(username string, password string) error {
|
||||
func (s *SQLStore) UpdateUserPassword(username, password string) error {
|
||||
now := time.Now().Unix()
|
||||
|
||||
query := s.getQueryBuilder().Update("users").
|
||||
|
@ -134,7 +134,7 @@ func (s *SQLStore) UpdateUserPassword(username string, password string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *SQLStore) UpdateUserPasswordByID(userID string, password string) error {
|
||||
func (s *SQLStore) UpdateUserPasswordByID(userID, password string) error {
|
||||
now := time.Now().Unix()
|
||||
|
||||
query := s.getQueryBuilder().Update("users").
|
||||
|
|
|
@ -5,7 +5,7 @@ import "github.com/mattermost/focalboard/server/model"
|
|||
|
||||
// Store represents the abstraction of the data storage.
|
||||
type Store interface {
|
||||
GetBlocksWithParentAndType(parentID string, blockType string) ([]model.Block, error)
|
||||
GetBlocksWithParentAndType(parentID, blockType string) ([]model.Block, error)
|
||||
GetBlocksWithParent(parentID string) ([]model.Block, error)
|
||||
GetBlocksWithType(blockType string) ([]model.Block, error)
|
||||
GetSubTree2(blockID string) ([]model.Block, error)
|
||||
|
@ -14,12 +14,12 @@ type Store interface {
|
|||
GetRootID(blockID string) (string, error)
|
||||
GetParentID(blockID string) (string, error)
|
||||
InsertBlock(block model.Block) error
|
||||
DeleteBlock(blockID string, modifiedBy string) error
|
||||
DeleteBlock(blockID, modifiedBy string) error
|
||||
|
||||
Shutdown() error
|
||||
|
||||
GetSystemSettings() (map[string]string, error)
|
||||
SetSystemSetting(key string, value string) error
|
||||
SetSystemSetting(key, value string) error
|
||||
|
||||
GetRegisteredUserCount() (int, error)
|
||||
GetUserById(userID string) (*model.User, error)
|
||||
|
@ -27,8 +27,8 @@ type Store interface {
|
|||
GetUserByUsername(username string) (*model.User, error)
|
||||
CreateUser(user *model.User) error
|
||||
UpdateUser(user *model.User) error
|
||||
UpdateUserPassword(username string, password string) error
|
||||
UpdateUserPasswordByID(userID string, password string) error
|
||||
UpdateUserPassword(username, password string) error
|
||||
UpdateUserPasswordByID(userID, password string) error
|
||||
|
||||
GetActiveUserCount(updatedSecondsAgo int64) (int, error)
|
||||
GetSession(token string, expireTime int64) (*model.Session, error)
|
||||
|
|
|
@ -81,7 +81,7 @@ func (ts *Service) sendTelemetry(event string, properties map[string]interface{}
|
|||
}
|
||||
}
|
||||
|
||||
func (ts *Service) initRudder(endpoint string, rudderKey string) {
|
||||
func (ts *Service) initRudder(endpoint, rudderKey string) {
|
||||
if ts.rudderClient == nil {
|
||||
config := rudder.Config{}
|
||||
config.Logger = rudder.StdLogger(ts.log)
|
||||
|
|
|
@ -29,7 +29,7 @@ type Server struct {
|
|||
}
|
||||
|
||||
// NewServer creates a new instance of the webserver.
|
||||
func NewServer(rootPath string, port int, ssl bool, localOnly bool) *Server {
|
||||
func NewServer(rootPath string, port int, ssl, localOnly bool) *Server {
|
||||
r := mux.NewRouter()
|
||||
|
||||
var addr string
|
||||
|
|
|
@ -146,7 +146,7 @@ func (ws *Server) isValidSessionToken(token string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (ws *Server) authenticateListener(wsSession *websocketSession, token string, readToken string) {
|
||||
func (ws *Server) authenticateListener(wsSession *websocketSession, token, readToken string) {
|
||||
// Authenticate session
|
||||
isValidSession := ws.isValidSessionToken(token)
|
||||
if !isValidSession {
|
||||
|
@ -267,7 +267,7 @@ func (ws *Server) getListeners(blockID string) []*websocket.Conn {
|
|||
}
|
||||
|
||||
// BroadcastBlockDelete broadcasts delete messages to clients
|
||||
func (ws *Server) BroadcastBlockDelete(blockID string, parentID string) {
|
||||
func (ws *Server) BroadcastBlockDelete(blockID, parentID string) {
|
||||
now := time.Now().Unix()
|
||||
block := model.Block{}
|
||||
block.ID = blockID
|
||||
|
|
Loading…
Reference in a new issue