diff --git a/server/api/api.go b/server/api/api.go index b054b290a..e47c5d3bb 100644 --- a/server/api/api.go +++ b/server/api/api.go @@ -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 { diff --git a/server/app/auth.go b/server/app/auth.go index bab17a22c..d9d0e09fa 100644 --- a/server/app/auth.go +++ b/server/app/auth.go @@ -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 diff --git a/server/app/blocks.go b/server/app/blocks.go index fbed8681b..0c94b585a 100644 --- a/server/app/blocks.go +++ b/server/app/blocks.go @@ -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 { diff --git a/server/auth/auth.go b/server/auth/auth.go index 2531a1070..f49cae5c9 100644 --- a/server/auth/auth.go +++ b/server/auth/auth.go @@ -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 diff --git a/server/client/client.go b/server/client/client.go index 58f3c19d8..56fad9258 100644 --- a/server/client/client.go +++ b/server/client/client.go @@ -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, "") } diff --git a/server/integrationtests/blocks_test.go b/server/integrationtests/blocks_test.go index bf5fa2303..daab1d006 100644 --- a/server/integrationtests/blocks_test.go +++ b/server/integrationtests/blocks_test.go @@ -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) { diff --git a/server/main/main.go b/server/main/main.go index b0311afc7..75ba13083 100644 --- a/server/main/main.go +++ b/server/main/main.go @@ -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 { diff --git a/server/model/version.go b/server/model/version.go index c767df425..ab3d2684b 100644 --- a/server/model/version.go +++ b/server/model/version.go @@ -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 +) diff --git a/server/services/auth/email.go b/server/services/auth/email.go index 814b263e0..f8f1d930f 100644 --- a/server/services/auth/email.go +++ b/server/services/auth/email.go @@ -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 { diff --git a/server/services/auth/password.go b/server/services/auth/password.go index 2915d8fe8..766d7323d 100644 --- a/server/services/auth/password.go +++ b/server/services/auth/password.go @@ -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 } diff --git a/server/services/store/sqlstore/blocks.go b/server/services/store/sqlstore/blocks.go index c1c8e6a8b..41d37d2f0 100644 --- a/server/services/store/sqlstore/blocks.go +++ b/server/services/store/sqlstore/blocks.go @@ -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( diff --git a/server/services/store/sqlstore/system.go b/server/services/store/sqlstore/system.go index 55013e6e4..a4286e87a 100644 --- a/server/services/store/sqlstore/system.go +++ b/server/services/store/sqlstore/system.go @@ -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() diff --git a/server/services/store/sqlstore/user.go b/server/services/store/sqlstore/user.go index 2e049ed7d..20c137e43 100644 --- a/server/services/store/sqlstore/user.go +++ b/server/services/store/sqlstore/user.go @@ -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"). diff --git a/server/services/store/store.go b/server/services/store/store.go index db8929249..91ece92b6 100644 --- a/server/services/store/store.go +++ b/server/services/store/store.go @@ -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) diff --git a/server/services/telemetry/telemetry.go b/server/services/telemetry/telemetry.go index be3fb6864..cca7bebf8 100644 --- a/server/services/telemetry/telemetry.go +++ b/server/services/telemetry/telemetry.go @@ -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) diff --git a/server/web/webserver.go b/server/web/webserver.go index 14e5d8fd6..50dd01a5d 100644 --- a/server/web/webserver.go +++ b/server/web/webserver.go @@ -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 diff --git a/server/ws/websockets.go b/server/ws/websockets.go index f485322d9..962c421e9 100644 --- a/server/ws/websockets.go +++ b/server/ws/websockets.go @@ -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