mirror of
https://github.com/mattermost/focalboard.git
synced 2025-01-23 18:34:02 +02:00
Also fix some gofmt issues https://mattermost.atlassian.net/browse/MM-49703
This commit is contained in:
parent
50e15f3804
commit
d6207dde6c
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@ -48,7 +48,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.1
|
go-version: 1.19.5
|
||||||
|
|
||||||
- name: "Test server: ${{matrix['db']}}"
|
- name: "Test server: ${{matrix['db']}}"
|
||||||
run: cd focalboard; make server-test-${{matrix['db']}}
|
run: cd focalboard; make server-test-${{matrix['db']}}
|
||||||
@ -83,7 +83,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.1
|
go-version: 1.19.5
|
||||||
|
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
@ -137,7 +137,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.1
|
go-version: 1.19.5
|
||||||
|
|
||||||
- name: "Test server (minimum): ${{matrix['db']}}"
|
- name: "Test server (minimum): ${{matrix['db']}}"
|
||||||
run: cd focalboard; make server-test-mini-${{matrix['db']}}
|
run: cd focalboard; make server-test-mini-${{matrix['db']}}
|
||||||
@ -174,7 +174,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.1
|
go-version: 1.19.5
|
||||||
|
|
||||||
- name: "Test server (minimum): ${{matrix['db']}}"
|
- name: "Test server (minimum): ${{matrix['db']}}"
|
||||||
run: cd focalboard; make server-test-mini-${{matrix['db']}}
|
run: cd focalboard; make server-test-mini-${{matrix['db']}}
|
||||||
|
8
.github/workflows/dev-release.yml
vendored
8
.github/workflows/dev-release.yml
vendored
@ -54,7 +54,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.1
|
go-version: 1.19.5
|
||||||
|
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
@ -129,7 +129,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.1
|
go-version: 1.19.5
|
||||||
|
|
||||||
- name: List Xcode versions
|
- name: List Xcode versions
|
||||||
run: ls -n /Applications/ | grep Xcode*
|
run: ls -n /Applications/ | grep Xcode*
|
||||||
@ -190,7 +190,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.1
|
go-version: 1.19.5
|
||||||
|
|
||||||
- name: Setup NuGet
|
- name: Setup NuGet
|
||||||
uses: nuget/setup-nuget@v1
|
uses: nuget/setup-nuget@v1
|
||||||
@ -258,7 +258,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.1
|
go-version: 1.19.5
|
||||||
|
|
||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
|
4
.github/workflows/lint-server.yml
vendored
4
.github/workflows/lint-server.yml
vendored
@ -30,7 +30,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/setup-go@v3
|
- uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.1
|
go-version: 1.19.5
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
path: "focalboard"
|
path: "focalboard"
|
||||||
@ -50,7 +50,7 @@ jobs:
|
|||||||
path: "mattermost-server"
|
path: "mattermost-server"
|
||||||
ref : "master"
|
ref : "master"
|
||||||
- name: set up golangci-lint
|
- 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
|
- name: lint
|
||||||
run: |
|
run: |
|
||||||
cd focalboard
|
cd focalboard
|
||||||
|
8
.github/workflows/prod-release.yml
vendored
8
.github/workflows/prod-release.yml
vendored
@ -50,7 +50,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.1
|
go-version: 1.19.5
|
||||||
|
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
@ -126,7 +126,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.1
|
go-version: 1.19.5
|
||||||
|
|
||||||
- name: List Xcode versions
|
- name: List Xcode versions
|
||||||
run: ls -n /Applications/ | grep Xcode*
|
run: ls -n /Applications/ | grep Xcode*
|
||||||
@ -188,7 +188,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.1
|
go-version: 1.19.5
|
||||||
|
|
||||||
- name: Setup NuGet
|
- name: Setup NuGet
|
||||||
uses: nuget/setup-nuget@v1
|
uses: nuget/setup-nuget@v1
|
||||||
@ -257,7 +257,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.1
|
go-version: 1.19.5
|
||||||
|
|
||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
|
@ -4,7 +4,7 @@ stages:
|
|||||||
|
|
||||||
variables:
|
variables:
|
||||||
BUILD: "yes"
|
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:
|
include:
|
||||||
- project: mattermost/ci/focalboard
|
- project: mattermost/ci/focalboard
|
||||||
|
@ -51,7 +51,7 @@ func makeGoWork(ci bool) string {
|
|||||||
|
|
||||||
var b strings.Builder
|
var b strings.Builder
|
||||||
|
|
||||||
b.WriteString("go 1.18\n\n")
|
b.WriteString("go 1.19\n\n")
|
||||||
b.WriteString("use ./server\n")
|
b.WriteString("use ./server\n")
|
||||||
|
|
||||||
for repo, envVarName := range repos {
|
for repo, envVarName := range repos {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module github.com/mattermost/focalboard/linux
|
module github.com/mattermost/focalboard/linux
|
||||||
|
|
||||||
go 1.18
|
go 1.19
|
||||||
|
|
||||||
replace github.com/mattermost/focalboard/server => ../server
|
replace github.com/mattermost/focalboard/server => ../server
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module github.com/mattermost/mattermost-plugin-starter-template/build
|
module github.com/mattermost/mattermost-plugin-starter-template/build
|
||||||
|
|
||||||
go 1.18
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-git/go-git/v5 v5.1.0
|
github.com/go-git/go-git/v5 v5.1.0
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module github.com/mattermost/focalboard/mattermost-plugin
|
module github.com/mattermost/focalboard/mattermost-plugin
|
||||||
|
|
||||||
go 1.18
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/golang/mock v1.6.0
|
github.com/golang/mock v1.6.0
|
||||||
|
@ -27,10 +27,7 @@ linters:
|
|||||||
enable:
|
enable:
|
||||||
- gofmt
|
- gofmt
|
||||||
- goimports
|
- goimports
|
||||||
- deadcode
|
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- structcheck
|
|
||||||
- varcheck
|
|
||||||
- unparam
|
- unparam
|
||||||
- errcheck
|
- errcheck
|
||||||
- govet
|
- govet
|
||||||
|
@ -220,7 +220,7 @@ func stringResponse(w http.ResponseWriter, message string) {
|
|||||||
_, _ = fmt.Fprint(w, message)
|
_, _ = 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")
|
setResponseHeader(w, "Content-Type", "application/json")
|
||||||
w.WriteHeader(code)
|
w.WriteHeader(code)
|
||||||
fmt.Fprint(w, message)
|
fmt.Fprint(w, message)
|
||||||
@ -232,7 +232,7 @@ func jsonBytesResponse(w http.ResponseWriter, code int, json []byte) {
|
|||||||
_, _ = w.Write(json)
|
_, _ = 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()
|
header := w.Header()
|
||||||
if header == nil {
|
if header == nil {
|
||||||
return
|
return
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// makeAuditRecord creates an audit record pre-populated with data from the request.
|
// 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()
|
ctx := r.Context()
|
||||||
var sessionID string
|
var sessionID string
|
||||||
var userID string
|
var userID string
|
||||||
|
@ -383,12 +383,13 @@ func (a *API) attachSession(handler func(w http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
authService := session.AuthService
|
authService := session.AuthService
|
||||||
if authService != a.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("sessionID", session.ID),
|
||||||
mlog.String("want", a.authService),
|
mlog.String("want", a.authService),
|
||||||
mlog.String("got", authService),
|
mlog.String("got", authService),
|
||||||
)
|
)
|
||||||
a.errorResponse(w, r, model.NewErrUnauthorized(err.Error()))
|
a.errorResponse(w, r, model.NewErrUnauthorized(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ func (a *API) handleAddMember(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if reqBoardMember.UserID == "" {
|
if reqBoardMember.UserID == "" {
|
||||||
a.errorResponse(w, r, model.NewErrBadRequest(err.Error()))
|
a.errorResponse(w, r, model.NewErrBadRequest("empty userID"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ func (a *App) GetTeamBoardsInsights(userID string, teamID string, opts *mmModel.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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) {
|
func (a *App) GetUserBoardsInsights(userID string, teamID string, opts *mmModel.InsightsOpts) (*model.BoardInsightsList, error) {
|
||||||
|
@ -51,7 +51,7 @@ func TestGetTeamAndUserBoardsInsights(t *testing.T) {
|
|||||||
th.Store.EXPECT().GetUserByID("user-id").Return(fakeUser, nil).AnyTimes()
|
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().GetBoardsForUserAndTeam("user-id", "team-id", true).Return(mockInsightsBoards, nil).AnyTimes()
|
||||||
th.Store.EXPECT().
|
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)
|
Return(mockTeamInsightsList, nil)
|
||||||
results, err := th.App.GetTeamBoardsInsights("user-id", "team-id", &mmModel.InsightsOpts{StartUnixMilli: 0, Page: 0, PerPage: 10})
|
results, err := th.App.GetTeamBoardsInsights("user-id", "team-id", &mmModel.InsightsOpts{StartUnixMilli: 0, Page: 0, PerPage: 10})
|
||||||
require.NoError(t, err)
|
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().GetUserByID("user-id").Return(fakeUser, nil).AnyTimes()
|
||||||
th.Store.EXPECT().GetBoardsForUserAndTeam("user-id", "team-id", true).Return(mockInsightsBoards, nil).AnyTimes()
|
th.Store.EXPECT().GetBoardsForUserAndTeam("user-id", "team-id", true).Return(mockInsightsBoards, nil).AnyTimes()
|
||||||
th.Store.EXPECT().
|
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"})
|
Return(nil, insightError{"board-insight-error"})
|
||||||
_, err := th.App.GetTeamBoardsInsights("user-id", "team-id", &mmModel.InsightsOpts{StartUnixMilli: 0, Page: 0, PerPage: 10})
|
_, err := th.App.GetTeamBoardsInsights("user-id", "team-id", &mmModel.InsightsOpts{StartUnixMilli: 0, Page: 0, PerPage: 10})
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
@ -7,5 +7,6 @@ import (
|
|||||||
// DefaultTemplatesArchive is an embedded archive file containing the default
|
// DefaultTemplatesArchive is an embedded archive file containing the default
|
||||||
// templates to be imported to team 0.
|
// templates to be imported to team 0.
|
||||||
// This archive is generated with `make templates-archive`
|
// This archive is generated with `make templates-archive`
|
||||||
|
//
|
||||||
//go:embed templates.boardarchive
|
//go:embed templates.boardarchive
|
||||||
var DefaultTemplatesArchive []byte
|
var DefaultTemplatesArchive []byte
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module github.com/mattermost/focalboard/server
|
module github.com/mattermost/focalboard/server
|
||||||
|
|
||||||
go 1.18
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Masterminds/squirrel v1.5.3
|
github.com/Masterminds/squirrel v1.5.3
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module github.com/mattermost/focalboard/server
|
module github.com/mattermost/focalboard/server
|
||||||
|
|
||||||
go 1.18
|
go 1.19
|
||||||
|
|
||||||
require github.com/golang/mock v1.6.0
|
require github.com/golang/mock v1.6.0
|
||||||
|
|
||||||
|
@ -269,9 +269,7 @@ func TestGetCard(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Helpers.
|
// Helpers.
|
||||||
//
|
|
||||||
func reverse(src []string) []string {
|
func reverse(src []string) []string {
|
||||||
out := make([]string, 0, len(src))
|
out := make([]string, 0, len(src))
|
||||||
for i := len(src) - 1; i >= 0; i-- {
|
for i := len(src) - 1; i >= 0; i-- {
|
||||||
|
@ -122,7 +122,7 @@ func main() {
|
|||||||
if pDBConfig != nil && len(*pDBConfig) > 0 {
|
if pDBConfig != nil && len(*pDBConfig) > 0 {
|
||||||
config.DBConfigString = *pDBConfig
|
config.DBConfigString = *pDBConfig
|
||||||
// Don't echo, as the confix string may contain passwords
|
// 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 {
|
if pPort != nil && *pPort > 0 && *pPort != config.Port {
|
||||||
@ -166,6 +166,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StartServer starts the server
|
// StartServer starts the server
|
||||||
|
//
|
||||||
//export StartServer
|
//export StartServer
|
||||||
func StartServer(webPath *C.char, filesPath *C.char, port int, singleUserToken, dbConfigString, configFilePath *C.char) {
|
func StartServer(webPath *C.char, filesPath *C.char, port int, singleUserToken, dbConfigString, configFilePath *C.char) {
|
||||||
startServer(
|
startServer(
|
||||||
@ -179,6 +180,7 @@ func StartServer(webPath *C.char, filesPath *C.char, port int, singleUserToken,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StopServer stops the server
|
// StopServer stops the server
|
||||||
|
//
|
||||||
//export StopServer
|
//export StopServer
|
||||||
func StopServer() {
|
func StopServer() {
|
||||||
stopServer()
|
stopServer()
|
||||||
|
@ -377,7 +377,7 @@ func (s *Server) UpdateAppConfig() {
|
|||||||
// Local server
|
// Local server
|
||||||
|
|
||||||
func (s *Server) startLocalModeServer() error {
|
func (s *Server) startLocalModeServer() error {
|
||||||
s.localModeServer = &http.Server{
|
s.localModeServer = &http.Server{ //nolint:gosec
|
||||||
Handler: s.localRouter,
|
Handler: s.localRouter,
|
||||||
ConnContext: api.SetContextConn,
|
ConnContext: api.SetContextConn,
|
||||||
}
|
}
|
||||||
|
@ -46,11 +46,13 @@ func NewAudit(options ...mlog.Option) (*Audit, error) {
|
|||||||
|
|
||||||
// Configure provides a new configuration for this audit service.
|
// Configure provides a new configuration for this audit service.
|
||||||
// Zero or more sources of config can be provided:
|
// Zero or more sources of config can be provided:
|
||||||
|
//
|
||||||
// cfgFile - path to file containing JSON
|
// cfgFile - path to file containing JSON
|
||||||
// cfgEscaped - JSON string probably from ENV var
|
// cfgEscaped - JSON string probably from ENV var
|
||||||
//
|
//
|
||||||
// For each case JSON containing log targets is provided. Target name collisions are resolved
|
// For each case JSON containing log targets is provided. Target name collisions are resolved
|
||||||
// using the following precedence:
|
// using the following precedence:
|
||||||
|
//
|
||||||
// cfgFile > cfgEscaped
|
// cfgFile > cfgEscaped
|
||||||
func (a *Audit) Configure(cfgFile string, cfgEscaped string) error {
|
func (a *Audit) Configure(cfgFile string, cfgEscaped string) error {
|
||||||
return a.auditLogger.Configure(cfgFile, cfgEscaped, nil)
|
return a.auditLogger.Configure(cfgFile, cfgEscaped, nil)
|
||||||
|
@ -17,7 +17,7 @@ type Service struct {
|
|||||||
// NewMetricsServer factory method to create a new prometheus server.
|
// NewMetricsServer factory method to create a new prometheus server.
|
||||||
func NewMetricsServer(address string, metricsService *Metrics, logger mlog.LoggerIFace) *Service {
|
func NewMetricsServer(address string, metricsService *Metrics, logger mlog.LoggerIFace) *Service {
|
||||||
return &Service{
|
return &Service{
|
||||||
&http.Server{
|
&http.Server{ //nolint:gosec
|
||||||
Addr: address,
|
Addr: address,
|
||||||
Handler: promhttp.HandlerFor(metricsService.registry, promhttp.HandlerOpts{
|
Handler: promhttp.HandlerFor(metricsService.registry, promhttp.HandlerOpts{
|
||||||
ErrorLog: logger.StdLogger(mlog.LvlError),
|
ErrorLog: logger.StdLogger(mlog.LvlError),
|
||||||
|
@ -599,7 +599,7 @@ func (s *MattermostAuthLayer) GetLicense() *mmModel.License {
|
|||||||
return s.servicesAPI.GetLicense()
|
return s.servicesAPI.GetLicense()
|
||||||
}
|
}
|
||||||
|
|
||||||
func boardFields(prefix string) []string {
|
func boardFields(prefix string) []string { //nolint:unparam
|
||||||
fields := []string{
|
fields := []string{
|
||||||
"id",
|
"id",
|
||||||
"team_id",
|
"team_id",
|
||||||
|
@ -999,18 +999,18 @@ func (mr *MockStoreMockRecorder) GetTeam(arg0 interface{}) *gomock.Call {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetTeamBoardsInsights mocks base method.
|
// 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()
|
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)
|
ret0, _ := ret[0].(*model.BoardInsightsList)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTeamBoardsInsights indicates an expected call of GetTeamBoardsInsights.
|
// 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()
|
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.
|
// GetTeamCount mocks base method.
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
"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).
|
boardsHistoryQuery := s.getQueryBuilder(db).
|
||||||
Select("boards.id, boards.icon, boards.title, count(boards_history.id) as count, boards_history.modified_by, boards.created_by").
|
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").
|
From(s.tablePrefix + "boards_history as boards_history").
|
||||||
|
@ -144,7 +144,7 @@ func (s *SQLStore) CreateUser(user *model.User) (*model.User, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SQLStore) DBVersion() string {
|
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) {
|
func (s *SQLStore) GetTeamBoardsInsights(teamID string, since int64, offset int, limit int, boardIDs []string) (*model.BoardInsightsList, error) {
|
||||||
return s.getTeamBoardsInsights(s.db, teamID, userID, since, offset, limit, boardIDs)
|
return s.getTeamBoardsInsights(s.db, teamID, since, offset, limit, boardIDs)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ func (s *SQLStore) getQueryBuilder(db sq.BaseRunner) sq.StatementBuilderType {
|
|||||||
return builder.RunWith(db)
|
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 {
|
if s.dbType == model.MysqlDBType {
|
||||||
return "`" + fieldName + "`"
|
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")
|
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 version string
|
||||||
var row *sql.Row
|
var row *sql.Row
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ type Store interface {
|
|||||||
SendMessage(message, postType string, receipts []string) error
|
SendMessage(message, postType string, receipts []string) error
|
||||||
|
|
||||||
// Insights
|
// 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)
|
GetUserBoardsInsights(teamID string, userID string, since int64, offset int, limit int, boardIDs []string) (*model.BoardInsightsList, error)
|
||||||
GetUserTimezone(userID string) (string, error)
|
GetUserTimezone(userID string) (string, error)
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ func getBoardsInsightsTest(t *testing.T, store store.Store) {
|
|||||||
boardsUser2, _ := store.GetBoardsForUserAndTeam(testInsightsUserID1, testTeamID, true)
|
boardsUser2, _ := store.GetBoardsForUserAndTeam(testInsightsUserID1, testTeamID, true)
|
||||||
t.Run("team insights", func(t *testing.T) {
|
t.Run("team insights", func(t *testing.T) {
|
||||||
boardIDs := []string{boardsUser1[0].ID, boardsUser1[1].ID, boardsUser1[2].ID}
|
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)
|
0, 0, 10, boardIDs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Len(t, topTeamBoards.Items, 3)
|
require.Len(t, topTeamBoards.Items, 3)
|
||||||
|
@ -59,7 +59,8 @@ func NewServer(rootPath string, serverRoot string, port int, ssl, localOnly bool
|
|||||||
baseURL = url.Path
|
baseURL = url.Path
|
||||||
|
|
||||||
ws := &Server{
|
ws := &Server{
|
||||||
Server: http.Server{
|
// (TODO: Add ReadHeaderTimeout)
|
||||||
|
Server: http.Server{ //nolint:gosec
|
||||||
Addr: addr,
|
Addr: addr,
|
||||||
Handler: r,
|
Handler: r,
|
||||||
},
|
},
|
||||||
|
@ -422,7 +422,7 @@ func (pa *PluginAdapter) sendTeamMessage(event, teamID string, payload map[strin
|
|||||||
EnsureUsers: ensureUserIDs,
|
EnsureUsers: ensureUserIDs,
|
||||||
}
|
}
|
||||||
|
|
||||||
pa.sendMessageToCluster("websocket_message", clusterMessage)
|
pa.sendMessageToCluster(clusterMessage)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
pa.sendTeamMessageSkipCluster(event, teamID, payload)
|
pa.sendTeamMessageSkipCluster(event, teamID, payload)
|
||||||
@ -447,7 +447,7 @@ func (pa *PluginAdapter) sendBoardMessage(teamID, boardID string, payload map[st
|
|||||||
EnsureUsers: ensureUserIDs,
|
EnsureUsers: ensureUserIDs,
|
||||||
}
|
}
|
||||||
|
|
||||||
pa.sendMessageToCluster("websocket_message", clusterMessage)
|
pa.sendMessageToCluster(clusterMessage)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
pa.sendBoardMessageSkipCluster(teamID, boardID, payload, ensureUserIDs...)
|
pa.sendBoardMessageSkipCluster(teamID, boardID, payload, ensureUserIDs...)
|
||||||
@ -490,7 +490,7 @@ func (pa *PluginAdapter) BroadcastCategoryChange(category model.Category) {
|
|||||||
UserID: category.UserID,
|
UserID: category.UserID,
|
||||||
}
|
}
|
||||||
|
|
||||||
pa.sendMessageToCluster("websocket_message", clusterMessage)
|
pa.sendMessageToCluster(clusterMessage)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
pa.sendUserMessageSkipCluster(websocketActionUpdateCategory, payload, category.UserID)
|
pa.sendUserMessageSkipCluster(websocketActionUpdateCategory, payload, category.UserID)
|
||||||
@ -514,7 +514,7 @@ func (pa *PluginAdapter) BroadcastCategoryReorder(teamID, userID string, categor
|
|||||||
UserID: userID,
|
UserID: userID,
|
||||||
}
|
}
|
||||||
|
|
||||||
pa.sendMessageToCluster("websocket_message", clusterMessage)
|
pa.sendMessageToCluster(clusterMessage)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
pa.sendUserMessageSkipCluster(message.Action, payload, userID)
|
pa.sendUserMessageSkipCluster(message.Action, payload, userID)
|
||||||
@ -540,7 +540,7 @@ func (pa *PluginAdapter) BroadcastCategoryBoardsReorder(teamID, userID, category
|
|||||||
UserID: userID,
|
UserID: userID,
|
||||||
}
|
}
|
||||||
|
|
||||||
pa.sendMessageToCluster("websocket_message", clusterMessage)
|
pa.sendMessageToCluster(clusterMessage)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
pa.sendUserMessageSkipCluster(message.Action, payload, userID)
|
pa.sendUserMessageSkipCluster(message.Action, payload, userID)
|
||||||
@ -568,7 +568,7 @@ func (pa *PluginAdapter) BroadcastCategoryBoardChange(teamID, userID string, boa
|
|||||||
UserID: userID,
|
UserID: userID,
|
||||||
}
|
}
|
||||||
|
|
||||||
pa.sendMessageToCluster("websocket_message", clusterMessage)
|
pa.sendMessageToCluster(clusterMessage)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
pa.sendUserMessageSkipCluster(websocketActionUpdateCategoryBoard, utils.StructToMap(message), userID)
|
pa.sendUserMessageSkipCluster(websocketActionUpdateCategoryBoard, utils.StructToMap(message), userID)
|
||||||
|
@ -15,7 +15,8 @@ type ClusterMessage struct {
|
|||||||
EnsureUsers []string
|
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)
|
b, err := json.Marshal(clusterMessage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
pa.logger.Error("couldn't get JSON bytes from cluster message",
|
pa.logger.Error("couldn't get JSON bytes from cluster message",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user