605c0079eb
* skeleton lifecycle * bare minimum to satisfy mm-server import * added boards_imports.go * move boards_imports.go to correct package * bump mmserver version; remove replace in go.mod; use module workspaces; remove logger service * rename product.go --> boards.go * add FileInfoStore and Cloud services for product; create minimal pluginAPI interfaces for all packages * rename Boards -> BoardsProduct * compile success * remove hooks service; guard for nil BoardsApp * update to latest mmserver ver * upgrade mmserver to master tip * upgrade mmserver to master tip * bump plugin-api to master tip * fix users service * fix OnActivate crash; normalize AppError returns * fileBackend interface for server/app * feature flag * bump mmserver version * fix linter errors * make go.work when linting * fix go.work creation for CI * add execute flag for script * fix more linter errors * always create a go.work * fix ci go.work * OS agnostic go.work generator * fix path * fix path again * partially disable cypress test * fix case Id --> ID * bump mmserver version * include in go.work for dev * addressed review comments. Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
110 lines
3.2 KiB
Go
110 lines
3.2 KiB
Go
package app
|
|
|
|
import (
|
|
"io"
|
|
"sync"
|
|
"time"
|
|
|
|
"github.com/mattermost/focalboard/server/auth"
|
|
"github.com/mattermost/focalboard/server/services/config"
|
|
"github.com/mattermost/focalboard/server/services/metrics"
|
|
"github.com/mattermost/focalboard/server/services/notify"
|
|
"github.com/mattermost/focalboard/server/services/permissions"
|
|
"github.com/mattermost/focalboard/server/services/store"
|
|
"github.com/mattermost/focalboard/server/services/webhook"
|
|
"github.com/mattermost/focalboard/server/utils"
|
|
"github.com/mattermost/focalboard/server/ws"
|
|
|
|
mm_model "github.com/mattermost/mattermost-server/v6/model"
|
|
"github.com/mattermost/mattermost-server/v6/shared/filestore"
|
|
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
|
)
|
|
|
|
const (
|
|
blockChangeNotifierQueueSize = 1000
|
|
blockChangeNotifierPoolSize = 10
|
|
blockChangeNotifierShutdownTimeout = time.Second * 10
|
|
)
|
|
|
|
type servicesAPI interface {
|
|
GetUsersFromProfiles(options *mm_model.UserGetOptions) ([]*mm_model.User, error)
|
|
}
|
|
|
|
type ReadCloseSeeker = filestore.ReadCloseSeeker
|
|
|
|
type fileBackend interface {
|
|
Reader(path string) (ReadCloseSeeker, error)
|
|
FileExists(path string) (bool, error)
|
|
CopyFile(oldPath, newPath string) error
|
|
MoveFile(oldPath, newPath string) error
|
|
WriteFile(fr io.Reader, path string) (int64, error)
|
|
RemoveFile(path string) error
|
|
}
|
|
|
|
type Services struct {
|
|
Auth *auth.Auth
|
|
Store store.Store
|
|
FilesBackend fileBackend
|
|
Webhook *webhook.Client
|
|
Metrics *metrics.Metrics
|
|
Notifications *notify.Service
|
|
Logger mlog.LoggerIFace
|
|
Permissions permissions.PermissionsService
|
|
SkipTemplateInit bool
|
|
ServicesAPI servicesAPI
|
|
}
|
|
|
|
type App struct {
|
|
config *config.Configuration
|
|
store store.Store
|
|
auth *auth.Auth
|
|
wsAdapter ws.Adapter
|
|
filesBackend fileBackend
|
|
webhook *webhook.Client
|
|
metrics *metrics.Metrics
|
|
notifications *notify.Service
|
|
logger mlog.LoggerIFace
|
|
blockChangeNotifier *utils.CallbackQueue
|
|
servicesAPI servicesAPI
|
|
|
|
cardLimitMux sync.RWMutex
|
|
cardLimit int
|
|
}
|
|
|
|
func (a *App) SetConfig(config *config.Configuration) {
|
|
a.config = config
|
|
}
|
|
|
|
func (a *App) GetConfig() *config.Configuration {
|
|
return a.config
|
|
}
|
|
|
|
func New(config *config.Configuration, wsAdapter ws.Adapter, services Services) *App {
|
|
app := &App{
|
|
config: config,
|
|
store: services.Store,
|
|
auth: services.Auth,
|
|
wsAdapter: wsAdapter,
|
|
filesBackend: services.FilesBackend,
|
|
webhook: services.Webhook,
|
|
metrics: services.Metrics,
|
|
notifications: services.Notifications,
|
|
logger: services.Logger,
|
|
blockChangeNotifier: utils.NewCallbackQueue("blockChangeNotifier", blockChangeNotifierQueueSize, blockChangeNotifierPoolSize, services.Logger),
|
|
servicesAPI: services.ServicesAPI,
|
|
}
|
|
app.initialize(services.SkipTemplateInit)
|
|
return app
|
|
}
|
|
|
|
func (a *App) CardLimit() int {
|
|
a.cardLimitMux.RLock()
|
|
defer a.cardLimitMux.RUnlock()
|
|
return a.cardLimit
|
|
}
|
|
|
|
func (a *App) SetCardLimit(cardLimit int) {
|
|
a.cardLimitMux.Lock()
|
|
defer a.cardLimitMux.Unlock()
|
|
a.cardLimit = cardLimit
|
|
}
|