diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 296435f5f..783c58582 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18.1 + go-version: 1.19.5 - name: "Test server: ${{matrix['db']}}" run: cd focalboard; make server-test-${{matrix['db']}} @@ -83,7 +83,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18.1 + go-version: 1.19.5 - name: Setup Node uses: actions/setup-node@v3 @@ -137,7 +137,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18.1 + go-version: 1.19.5 - name: "Test server (minimum): ${{matrix['db']}}" run: cd focalboard; make server-test-mini-${{matrix['db']}} @@ -174,7 +174,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18.1 + go-version: 1.19.5 - name: "Test server (minimum): ${{matrix['db']}}" run: cd focalboard; make server-test-mini-${{matrix['db']}} diff --git a/.github/workflows/dev-release.yml b/.github/workflows/dev-release.yml index 2376c1f1d..9ebf34df6 100644 --- a/.github/workflows/dev-release.yml +++ b/.github/workflows/dev-release.yml @@ -54,7 +54,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18.1 + go-version: 1.19.5 - name: Setup Node uses: actions/setup-node@v3 @@ -129,7 +129,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18.1 + go-version: 1.19.5 - name: List Xcode versions run: ls -n /Applications/ | grep Xcode* @@ -190,7 +190,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18.1 + go-version: 1.19.5 - name: Setup NuGet uses: nuget/setup-nuget@v1 @@ -258,7 +258,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18.1 + go-version: 1.19.5 - name: Set up Node uses: actions/setup-node@v3 diff --git a/.github/workflows/lint-server.yml b/.github/workflows/lint-server.yml index eb5093406..3c114e71b 100644 --- a/.github/workflows/lint-server.yml +++ b/.github/workflows/lint-server.yml @@ -30,7 +30,7 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: 1.18.1 + go-version: 1.19.5 - uses: actions/checkout@v3 with: path: "focalboard" @@ -50,7 +50,7 @@ jobs: path: "mattermost-server" ref : "master" - name: set up golangci-lint - run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2 + run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.1 - name: lint run: | cd focalboard diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index feb078617..8ca6f4f98 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -50,7 +50,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18.1 + go-version: 1.19.5 - name: Setup Node uses: actions/setup-node@v3 @@ -126,7 +126,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18.1 + go-version: 1.19.5 - name: List Xcode versions run: ls -n /Applications/ | grep Xcode* @@ -188,7 +188,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18.1 + go-version: 1.19.5 - name: Setup NuGet uses: nuget/setup-nuget@v1 @@ -257,7 +257,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18.1 + go-version: 1.19.5 - name: Set up Node uses: actions/setup-node@v3 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 09944dba2..f6107d60f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: variables: BUILD: "yes" - IMAGE_BUILDER: $CI_REGISTRY/mattermost/ci/images/builder:go-1.18.1-node-16.15.0-1 + IMAGE_BUILDER: $CI_REGISTRY/mattermost/ci/images/builder:go-1.19.5-node-16.15.0-1 include: - project: mattermost/ci/focalboard diff --git a/build/gowork/main.go b/build/gowork/main.go index c962369d5..b8619ebdf 100644 --- a/build/gowork/main.go +++ b/build/gowork/main.go @@ -51,7 +51,7 @@ func makeGoWork(ci bool) string { var b strings.Builder - b.WriteString("go 1.18\n\n") + b.WriteString("go 1.19\n\n") b.WriteString("use ./server\n") for repo, envVarName := range repos { diff --git a/linux/go.mod b/linux/go.mod index b5a89f917..497722568 100644 --- a/linux/go.mod +++ b/linux/go.mod @@ -1,6 +1,6 @@ module github.com/mattermost/focalboard/linux -go 1.18 +go 1.19 replace github.com/mattermost/focalboard/server => ../server diff --git a/mattermost-plugin/build/go.mod b/mattermost-plugin/build/go.mod index 679c3003e..0ba2a34ef 100644 --- a/mattermost-plugin/build/go.mod +++ b/mattermost-plugin/build/go.mod @@ -1,6 +1,6 @@ module github.com/mattermost/mattermost-plugin-starter-template/build -go 1.18 +go 1.19 require ( github.com/go-git/go-git/v5 v5.1.0 diff --git a/mattermost-plugin/go.mod b/mattermost-plugin/go.mod index b36f6db8d..8e3fd146a 100644 --- a/mattermost-plugin/go.mod +++ b/mattermost-plugin/go.mod @@ -1,6 +1,6 @@ module github.com/mattermost/focalboard/mattermost-plugin -go 1.18 +go 1.19 require ( github.com/golang/mock v1.6.0 diff --git a/server/.golangci.yml b/server/.golangci.yml index c1381759f..23f4fce36 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -27,10 +27,7 @@ linters: enable: - gofmt - goimports - - deadcode - ineffassign - - structcheck - - varcheck - unparam - errcheck - govet diff --git a/server/api/api.go b/server/api/api.go index da87f0b24..3f3dcb418 100644 --- a/server/api/api.go +++ b/server/api/api.go @@ -220,7 +220,7 @@ func stringResponse(w http.ResponseWriter, message string) { _, _ = fmt.Fprint(w, message) } -func jsonStringResponse(w http.ResponseWriter, code int, message string) { +func jsonStringResponse(w http.ResponseWriter, code int, message string) { //nolint:unparam setResponseHeader(w, "Content-Type", "application/json") w.WriteHeader(code) fmt.Fprint(w, message) @@ -232,7 +232,7 @@ func jsonBytesResponse(w http.ResponseWriter, code int, json []byte) { _, _ = w.Write(json) } -func setResponseHeader(w http.ResponseWriter, key string, value string) { +func setResponseHeader(w http.ResponseWriter, key string, value string) { //nolint:unparam header := w.Header() if header == nil { return diff --git a/server/api/audit.go b/server/api/audit.go index dba563ffb..875f5c28c 100644 --- a/server/api/audit.go +++ b/server/api/audit.go @@ -8,7 +8,7 @@ import ( ) // makeAuditRecord creates an audit record pre-populated with data from the request. -func (a *API) makeAuditRecord(r *http.Request, event string, initialStatus string) *audit.Record { +func (a *API) makeAuditRecord(r *http.Request, event string, initialStatus string) *audit.Record { //nolint:unparam ctx := r.Context() var sessionID string var userID string diff --git a/server/api/auth.go b/server/api/auth.go index dffe86f18..b81660ab2 100644 --- a/server/api/auth.go +++ b/server/api/auth.go @@ -383,12 +383,13 @@ func (a *API) attachSession(handler func(w http.ResponseWriter, r *http.Request) authService := session.AuthService if authService != a.authService { - a.logger.Error(`Session authService mismatch`, + msg := `Session authService mismatch` + a.logger.Error(msg, mlog.String("sessionID", session.ID), mlog.String("want", a.authService), mlog.String("got", authService), ) - a.errorResponse(w, r, model.NewErrUnauthorized(err.Error())) + a.errorResponse(w, r, model.NewErrUnauthorized(msg)) return } diff --git a/server/api/members.go b/server/api/members.go index 3b5dff592..2014b84f3 100644 --- a/server/api/members.go +++ b/server/api/members.go @@ -146,7 +146,7 @@ func (a *API) handleAddMember(w http.ResponseWriter, r *http.Request) { } if reqBoardMember.UserID == "" { - a.errorResponse(w, r, model.NewErrBadRequest(err.Error())) + a.errorResponse(w, r, model.NewErrBadRequest("empty userID")) return } diff --git a/server/app/insights.go b/server/app/insights.go index 28027d54d..9179a86c2 100644 --- a/server/app/insights.go +++ b/server/app/insights.go @@ -19,7 +19,7 @@ func (a *App) GetTeamBoardsInsights(userID string, teamID string, opts *mmModel. if err != nil { return nil, err } - return a.store.GetTeamBoardsInsights(teamID, userID, opts.StartUnixMilli, opts.Page*opts.PerPage, opts.PerPage, boardIDs) + return a.store.GetTeamBoardsInsights(teamID, opts.StartUnixMilli, opts.Page*opts.PerPage, opts.PerPage, boardIDs) } func (a *App) GetUserBoardsInsights(userID string, teamID string, opts *mmModel.InsightsOpts) (*model.BoardInsightsList, error) { diff --git a/server/app/insights_test.go b/server/app/insights_test.go index 9a419c79e..c6897ff24 100644 --- a/server/app/insights_test.go +++ b/server/app/insights_test.go @@ -51,7 +51,7 @@ func TestGetTeamAndUserBoardsInsights(t *testing.T) { th.Store.EXPECT().GetUserByID("user-id").Return(fakeUser, nil).AnyTimes() th.Store.EXPECT().GetBoardsForUserAndTeam("user-id", "team-id", true).Return(mockInsightsBoards, nil).AnyTimes() th.Store.EXPECT(). - GetTeamBoardsInsights("team-id", "user-id", int64(0), 0, 10, []string{"mock-user-workspace-id"}). + GetTeamBoardsInsights("team-id", int64(0), 0, 10, []string{"mock-user-workspace-id"}). Return(mockTeamInsightsList, nil) results, err := th.App.GetTeamBoardsInsights("user-id", "team-id", &mmModel.InsightsOpts{StartUnixMilli: 0, Page: 0, PerPage: 10}) require.NoError(t, err) @@ -74,7 +74,7 @@ func TestGetTeamAndUserBoardsInsights(t *testing.T) { th.Store.EXPECT().GetUserByID("user-id").Return(fakeUser, nil).AnyTimes() th.Store.EXPECT().GetBoardsForUserAndTeam("user-id", "team-id", true).Return(mockInsightsBoards, nil).AnyTimes() th.Store.EXPECT(). - GetTeamBoardsInsights("team-id", "user-id", int64(0), 0, 10, []string{"mock-user-workspace-id"}). + GetTeamBoardsInsights("team-id", int64(0), 0, 10, []string{"mock-user-workspace-id"}). Return(nil, insightError{"board-insight-error"}) _, err := th.App.GetTeamBoardsInsights("user-id", "team-id", &mmModel.InsightsOpts{StartUnixMilli: 0, Page: 0, PerPage: 10}) require.Error(t, err) diff --git a/server/assets/assets.go b/server/assets/assets.go index 4eeecefb9..b558d4e80 100644 --- a/server/assets/assets.go +++ b/server/assets/assets.go @@ -7,5 +7,6 @@ import ( // DefaultTemplatesArchive is an embedded archive file containing the default // templates to be imported to team 0. // This archive is generated with `make templates-archive` +// //go:embed templates.boardarchive var DefaultTemplatesArchive []byte diff --git a/server/go.mod b/server/go.mod index 6dd50b088..fa923cb1c 100644 --- a/server/go.mod +++ b/server/go.mod @@ -1,6 +1,6 @@ module github.com/mattermost/focalboard/server -go 1.18 +go 1.19 require ( github.com/Masterminds/squirrel v1.5.3 diff --git a/server/go.tools.mod b/server/go.tools.mod index 32450070e..ee3a74487 100644 --- a/server/go.tools.mod +++ b/server/go.tools.mod @@ -1,6 +1,6 @@ module github.com/mattermost/focalboard/server -go 1.18 +go 1.19 require github.com/golang/mock v1.6.0 diff --git a/server/integrationtests/cards_test.go b/server/integrationtests/cards_test.go index 8cd51fd59..a6ec5f7d8 100644 --- a/server/integrationtests/cards_test.go +++ b/server/integrationtests/cards_test.go @@ -269,9 +269,7 @@ func TestGetCard(t *testing.T) { }) } -// // Helpers. -// func reverse(src []string) []string { out := make([]string, 0, len(src)) for i := len(src) - 1; i >= 0; i-- { diff --git a/server/main/main.go b/server/main/main.go index ba7298f91..31eaa7d14 100644 --- a/server/main/main.go +++ b/server/main/main.go @@ -122,7 +122,7 @@ func main() { if pDBConfig != nil && len(*pDBConfig) > 0 { config.DBConfigString = *pDBConfig // Don't echo, as the confix string may contain passwords - logger.Info("DBConfigString overriden from commandline") + logger.Info("DBConfigString overridden from commandline") } if pPort != nil && *pPort > 0 && *pPort != config.Port { @@ -166,6 +166,7 @@ func main() { } // StartServer starts the server +// //export StartServer func StartServer(webPath *C.char, filesPath *C.char, port int, singleUserToken, dbConfigString, configFilePath *C.char) { startServer( @@ -179,6 +180,7 @@ func StartServer(webPath *C.char, filesPath *C.char, port int, singleUserToken, } // StopServer stops the server +// //export StopServer func StopServer() { stopServer() diff --git a/server/server/server.go b/server/server/server.go index fa72b42fa..b7e939c1c 100644 --- a/server/server/server.go +++ b/server/server/server.go @@ -377,7 +377,7 @@ func (s *Server) UpdateAppConfig() { // Local server func (s *Server) startLocalModeServer() error { - s.localModeServer = &http.Server{ + s.localModeServer = &http.Server{ //nolint:gosec Handler: s.localRouter, ConnContext: api.SetContextConn, } diff --git a/server/services/audit/audit.go b/server/services/audit/audit.go index 51b196b1e..cfb240097 100644 --- a/server/services/audit/audit.go +++ b/server/services/audit/audit.go @@ -46,12 +46,14 @@ func NewAudit(options ...mlog.Option) (*Audit, error) { // Configure provides a new configuration for this audit service. // Zero or more sources of config can be provided: -// cfgFile - path to file containing JSON -// cfgEscaped - JSON string probably from ENV var +// +// cfgFile - path to file containing JSON +// cfgEscaped - JSON string probably from ENV var // // For each case JSON containing log targets is provided. Target name collisions are resolved // using the following precedence: -// cfgFile > cfgEscaped +// +// cfgFile > cfgEscaped func (a *Audit) Configure(cfgFile string, cfgEscaped string) error { return a.auditLogger.Configure(cfgFile, cfgEscaped, nil) } diff --git a/server/services/metrics/service.go b/server/services/metrics/service.go index 5345e1f03..415da04b6 100644 --- a/server/services/metrics/service.go +++ b/server/services/metrics/service.go @@ -17,7 +17,7 @@ type Service struct { // NewMetricsServer factory method to create a new prometheus server. func NewMetricsServer(address string, metricsService *Metrics, logger mlog.LoggerIFace) *Service { return &Service{ - &http.Server{ + &http.Server{ //nolint:gosec Addr: address, Handler: promhttp.HandlerFor(metricsService.registry, promhttp.HandlerOpts{ ErrorLog: logger.StdLogger(mlog.LvlError), diff --git a/server/services/store/mattermostauthlayer/mattermostauthlayer.go b/server/services/store/mattermostauthlayer/mattermostauthlayer.go index d2b86e893..2696b382c 100644 --- a/server/services/store/mattermostauthlayer/mattermostauthlayer.go +++ b/server/services/store/mattermostauthlayer/mattermostauthlayer.go @@ -599,7 +599,7 @@ func (s *MattermostAuthLayer) GetLicense() *mmModel.License { return s.servicesAPI.GetLicense() } -func boardFields(prefix string) []string { +func boardFields(prefix string) []string { //nolint:unparam fields := []string{ "id", "team_id", diff --git a/server/services/store/mockstore/mockstore.go b/server/services/store/mockstore/mockstore.go index 63813e7a7..be3c588d4 100644 --- a/server/services/store/mockstore/mockstore.go +++ b/server/services/store/mockstore/mockstore.go @@ -999,18 +999,18 @@ func (mr *MockStoreMockRecorder) GetTeam(arg0 interface{}) *gomock.Call { } // GetTeamBoardsInsights mocks base method. -func (m *MockStore) GetTeamBoardsInsights(arg0, arg1 string, arg2 int64, arg3, arg4 int, arg5 []string) (*model.BoardInsightsList, error) { +func (m *MockStore) GetTeamBoardsInsights(arg0 string, arg1 int64, arg2, arg3 int, arg4 []string) (*model.BoardInsightsList, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTeamBoardsInsights", arg0, arg1, arg2, arg3, arg4, arg5) + ret := m.ctrl.Call(m, "GetTeamBoardsInsights", arg0, arg1, arg2, arg3, arg4) ret0, _ := ret[0].(*model.BoardInsightsList) ret1, _ := ret[1].(error) return ret0, ret1 } // GetTeamBoardsInsights indicates an expected call of GetTeamBoardsInsights. -func (mr *MockStoreMockRecorder) GetTeamBoardsInsights(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { +func (mr *MockStoreMockRecorder) GetTeamBoardsInsights(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTeamBoardsInsights", reflect.TypeOf((*MockStore)(nil).GetTeamBoardsInsights), arg0, arg1, arg2, arg3, arg4, arg5) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTeamBoardsInsights", reflect.TypeOf((*MockStore)(nil).GetTeamBoardsInsights), arg0, arg1, arg2, arg3, arg4) } // GetTeamCount mocks base method. diff --git a/server/services/store/sqlstore/board_insights.go b/server/services/store/sqlstore/board_insights.go index 73c92c9f6..8f4dad92e 100644 --- a/server/services/store/sqlstore/board_insights.go +++ b/server/services/store/sqlstore/board_insights.go @@ -14,7 +14,7 @@ import ( "github.com/mattermost/mattermost-server/v6/shared/mlog" ) -func (s *SQLStore) getTeamBoardsInsights(db sq.BaseRunner, teamID string, userID string, since int64, offset int, limit int, boardIDs []string) (*model.BoardInsightsList, error) { +func (s *SQLStore) getTeamBoardsInsights(db sq.BaseRunner, teamID string, since int64, offset int, limit int, boardIDs []string) (*model.BoardInsightsList, error) { boardsHistoryQuery := s.getQueryBuilder(db). Select("boards.id, boards.icon, boards.title, count(boards_history.id) as count, boards_history.modified_by, boards.created_by"). From(s.tablePrefix + "boards_history as boards_history"). diff --git a/server/services/store/sqlstore/public_methods.go b/server/services/store/sqlstore/public_methods.go index e3acf4955..e484d676a 100644 --- a/server/services/store/sqlstore/public_methods.go +++ b/server/services/store/sqlstore/public_methods.go @@ -144,7 +144,7 @@ func (s *SQLStore) CreateUser(user *model.User) (*model.User, error) { } func (s *SQLStore) DBVersion() string { - return s.dBVersion(s.db) + return s.dBVersion() } @@ -513,8 +513,8 @@ func (s *SQLStore) GetTeam(ID string) (*model.Team, error) { } -func (s *SQLStore) GetTeamBoardsInsights(teamID string, userID string, since int64, offset int, limit int, boardIDs []string) (*model.BoardInsightsList, error) { - return s.getTeamBoardsInsights(s.db, teamID, userID, since, offset, limit, boardIDs) +func (s *SQLStore) GetTeamBoardsInsights(teamID string, since int64, offset int, limit int, boardIDs []string) (*model.BoardInsightsList, error) { + return s.getTeamBoardsInsights(s.db, teamID, since, offset, limit, boardIDs) } diff --git a/server/services/store/sqlstore/sqlstore.go b/server/services/store/sqlstore/sqlstore.go index 854886d8d..7d7f36ade 100644 --- a/server/services/store/sqlstore/sqlstore.go +++ b/server/services/store/sqlstore/sqlstore.go @@ -136,7 +136,7 @@ func (s *SQLStore) getQueryBuilder(db sq.BaseRunner) sq.StatementBuilderType { return builder.RunWith(db) } -func (s *SQLStore) escapeField(fieldName string) string { +func (s *SQLStore) escapeField(fieldName string) string { //nolint:unparam if s.dbType == model.MysqlDBType { return "`" + fieldName + "`" } @@ -185,7 +185,7 @@ func (s *SQLStore) getChannel(db sq.BaseRunner, teamID, channel string) (*mmMode return nil, store.NewNotSupportedError("get channel not supported on standalone mode") } -func (s *SQLStore) dBVersion(db sq.BaseRunner) string { +func (s *SQLStore) dBVersion() string { var version string var row *sql.Row diff --git a/server/services/store/store.go b/server/services/store/store.go index ac1f4fc37..eb9fabedb 100644 --- a/server/services/store/store.go +++ b/server/services/store/store.go @@ -168,7 +168,7 @@ type Store interface { SendMessage(message, postType string, receipts []string) error // Insights - GetTeamBoardsInsights(teamID string, userID string, since int64, offset int, limit int, boardIDs []string) (*model.BoardInsightsList, error) + GetTeamBoardsInsights(teamID string, since int64, offset int, limit int, boardIDs []string) (*model.BoardInsightsList, error) GetUserBoardsInsights(teamID string, userID string, since int64, offset int, limit int, boardIDs []string) (*model.BoardInsightsList, error) GetUserTimezone(userID string) (string, error) diff --git a/server/services/store/storetests/board_insights.go b/server/services/store/storetests/board_insights.go index 85470cd47..f13091568 100644 --- a/server/services/store/storetests/board_insights.go +++ b/server/services/store/storetests/board_insights.go @@ -72,7 +72,7 @@ func getBoardsInsightsTest(t *testing.T, store store.Store) { boardsUser2, _ := store.GetBoardsForUserAndTeam(testInsightsUserID1, testTeamID, true) t.Run("team insights", func(t *testing.T) { boardIDs := []string{boardsUser1[0].ID, boardsUser1[1].ID, boardsUser1[2].ID} - topTeamBoards, err := store.GetTeamBoardsInsights(testTeamID, testUserID, + topTeamBoards, err := store.GetTeamBoardsInsights(testTeamID, 0, 0, 10, boardIDs) require.NoError(t, err) require.Len(t, topTeamBoards.Items, 3) diff --git a/server/web/webserver.go b/server/web/webserver.go index 237c7f40f..ad0539078 100644 --- a/server/web/webserver.go +++ b/server/web/webserver.go @@ -59,7 +59,8 @@ func NewServer(rootPath string, serverRoot string, port int, ssl, localOnly bool baseURL = url.Path ws := &Server{ - Server: http.Server{ + // (TODO: Add ReadHeaderTimeout) + Server: http.Server{ //nolint:gosec Addr: addr, Handler: r, }, diff --git a/server/ws/plugin_adapter.go b/server/ws/plugin_adapter.go index f45cae629..65cafb09b 100644 --- a/server/ws/plugin_adapter.go +++ b/server/ws/plugin_adapter.go @@ -422,7 +422,7 @@ func (pa *PluginAdapter) sendTeamMessage(event, teamID string, payload map[strin EnsureUsers: ensureUserIDs, } - pa.sendMessageToCluster("websocket_message", clusterMessage) + pa.sendMessageToCluster(clusterMessage) }() pa.sendTeamMessageSkipCluster(event, teamID, payload) @@ -447,7 +447,7 @@ func (pa *PluginAdapter) sendBoardMessage(teamID, boardID string, payload map[st EnsureUsers: ensureUserIDs, } - pa.sendMessageToCluster("websocket_message", clusterMessage) + pa.sendMessageToCluster(clusterMessage) }() pa.sendBoardMessageSkipCluster(teamID, boardID, payload, ensureUserIDs...) @@ -490,7 +490,7 @@ func (pa *PluginAdapter) BroadcastCategoryChange(category model.Category) { UserID: category.UserID, } - pa.sendMessageToCluster("websocket_message", clusterMessage) + pa.sendMessageToCluster(clusterMessage) }() pa.sendUserMessageSkipCluster(websocketActionUpdateCategory, payload, category.UserID) @@ -514,7 +514,7 @@ func (pa *PluginAdapter) BroadcastCategoryReorder(teamID, userID string, categor UserID: userID, } - pa.sendMessageToCluster("websocket_message", clusterMessage) + pa.sendMessageToCluster(clusterMessage) }() pa.sendUserMessageSkipCluster(message.Action, payload, userID) @@ -540,7 +540,7 @@ func (pa *PluginAdapter) BroadcastCategoryBoardsReorder(teamID, userID, category UserID: userID, } - pa.sendMessageToCluster("websocket_message", clusterMessage) + pa.sendMessageToCluster(clusterMessage) }() pa.sendUserMessageSkipCluster(message.Action, payload, userID) @@ -568,7 +568,7 @@ func (pa *PluginAdapter) BroadcastCategoryBoardChange(teamID, userID string, boa UserID: userID, } - pa.sendMessageToCluster("websocket_message", clusterMessage) + pa.sendMessageToCluster(clusterMessage) }() pa.sendUserMessageSkipCluster(websocketActionUpdateCategoryBoard, utils.StructToMap(message), userID) diff --git a/server/ws/plugin_adapter_cluster.go b/server/ws/plugin_adapter_cluster.go index 754b86afa..f326a61b7 100644 --- a/server/ws/plugin_adapter_cluster.go +++ b/server/ws/plugin_adapter_cluster.go @@ -15,7 +15,8 @@ type ClusterMessage struct { EnsureUsers []string } -func (pa *PluginAdapter) sendMessageToCluster(id string, clusterMessage *ClusterMessage) { +func (pa *PluginAdapter) sendMessageToCluster(clusterMessage *ClusterMessage) { + const id = "websocket_message" b, err := json.Marshal(clusterMessage) if err != nil { pa.logger.Error("couldn't get JSON bytes from cluster message",