1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-01-17 18:26:17 +02:00

Prepare for mono-repo (#4595)

* Move boardsProduct and boardsApp out of mattermost-plugin directory.

* wip

* fix cyclic imports

* rename boardsapp

* remove mattermost-plugin/server

* Revert "remove mattermost-plugin/server"

This reverts commit 7b95e4d2ffeb74b6a3ffe7068a61598bc71a44dd.
This commit is contained in:
Doug Lauder 2023-02-22 06:38:44 -05:00 committed by GitHub
parent 992c9c4e3e
commit 9eceed5075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 181 additions and 188 deletions

View File

@ -1,124 +0,0 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package boards
import (
"testing"
"github.com/golang/mock/gomock"
"github.com/mattermost/focalboard/server/integrationtests"
"github.com/mattermost/focalboard/server/model"
"github.com/mattermost/focalboard/server/server"
"github.com/mattermost/focalboard/server/ws"
mockservicesapi "github.com/mattermost/focalboard/server/model/mocks"
serverModel "github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type TestHelper struct {
Server *server.Server
}
func SetupTestHelper(t *testing.T) (*TestHelper, func()) {
th := &TestHelper{}
th.Server = newTestServer()
err := th.Server.Start()
require.NoError(t, err, "Server start should not error")
tearDown := func() {
err := th.Server.Shutdown()
require.NoError(t, err, "Server shutdown should not error")
}
return th, tearDown
}
func newTestServer() *server.Server {
return integrationtests.NewTestServerPluginMode()
}
func TestConfigurationNullConfiguration(t *testing.T) {
boardsApp := &BoardsApp{}
assert.NotNil(t, boardsApp.getConfiguration())
}
func TestOnConfigurationChange(t *testing.T) {
stringRef := ""
basePlugins := make(map[string]map[string]interface{})
basePlugins[PluginName] = make(map[string]interface{})
basePlugins[PluginName][SharedBoardsName] = true
baseFeatureFlags := &serverModel.FeatureFlags{
BoardsFeatureFlags: "Feature1-Feature2",
}
basePluginSettings := &serverModel.PluginSettings{
Directory: &stringRef,
Plugins: basePlugins,
}
intRef := 365
baseDataRetentionSettings := &serverModel.DataRetentionSettings{
BoardsRetentionDays: &intRef,
}
usernameRef := "username"
baseTeamSettings := &serverModel.TeamSettings{
TeammateNameDisplay: &usernameRef,
}
falseRef := false
basePrivacySettings := &serverModel.PrivacySettings{
ShowEmailAddress: &falseRef,
ShowFullName: &falseRef,
}
baseConfig := &serverModel.Config{
FeatureFlags: baseFeatureFlags,
PluginSettings: *basePluginSettings,
DataRetentionSettings: *baseDataRetentionSettings,
TeamSettings: *baseTeamSettings,
PrivacySettings: *basePrivacySettings,
}
t.Run("Test Load Plugin Success", func(t *testing.T) {
th, tearDown := SetupTestHelper(t)
defer tearDown()
ctrl := gomock.NewController(t)
api := mockservicesapi.NewMockServicesAPI(ctrl)
api.EXPECT().GetConfig().Return(baseConfig)
b := &BoardsApp{
server: th.Server,
wsPluginAdapter: &FakePluginAdapter{},
servicesAPI: api,
logger: mlog.CreateConsoleTestLogger(true, mlog.LvlError),
}
err := b.OnConfigurationChange()
assert.NoError(t, err)
assert.Equal(t, 1, count)
// make sure both App and Server got updated
assert.True(t, b.server.Config().EnablePublicSharedBoards)
assert.True(t, b.server.App().GetClientConfig().EnablePublicSharedBoards)
assert.Equal(t, "true", b.server.Config().FeatureFlags["Feature1"])
assert.Equal(t, "true", b.server.Config().FeatureFlags["Feature2"])
assert.Equal(t, "", b.server.Config().FeatureFlags["Feature3"])
})
}
var count = 0
type FakePluginAdapter struct {
ws.PluginAdapter
}
func (c *FakePluginAdapter) BroadcastConfigChange(clientConfig model.ClientConfig) {
count++
}

View File

@ -8,8 +8,8 @@ import (
"fmt"
"net/http"
"github.com/mattermost/focalboard/mattermost-plugin/server/boards"
"github.com/mattermost/focalboard/server/model"
"github.com/mattermost/focalboard/server/server"
pluginapi "github.com/mattermost/mattermost-plugin-api"
@ -24,7 +24,7 @@ var ErrPluginNotAllowed = errors.New("boards plugin not allowed while Boards pro
type Plugin struct {
plugin.MattermostPlugin
boardsApp *boards.BoardsApp
boardsApp *server.BoardsService
}
func (p *Plugin) OnActivate() error {
@ -48,7 +48,7 @@ func (p *Plugin) OnActivate() error {
adapter := newServiceAPIAdapter(p.API, client.Store, logger)
boardsApp, err := boards.NewBoardsApp(adapter)
boardsApp, err := server.NewBoardsService(adapter)
if err != nil {
return fmt.Errorf("cannot activate plugin: %w", err)
}

View File

@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package boards
package integrationtests
import (
"io"
@ -11,6 +11,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/mattermost/focalboard/server/server"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
)
@ -69,7 +71,7 @@ func TestSetConfiguration(t *testing.T) {
mmConfig := baseConfig
mmConfig.LogSettings = *logSettings
config := createBoardsConfig(*mmConfig, "", "testId")
config := server.CreateBoardsConfig(*mmConfig, "", "testId")
assert.Equal(t, true, config.Telemetry)
assert.Equal(t, "testId", config.TelemetryID)
})
@ -77,9 +79,9 @@ func TestSetConfiguration(t *testing.T) {
t.Run("test enable shared boards", func(t *testing.T) {
mmConfig := baseConfig
mmConfig.PluginSettings.Plugins = make(map[string]map[string]interface{})
mmConfig.PluginSettings.Plugins[PluginName] = make(map[string]interface{})
mmConfig.PluginSettings.Plugins[PluginName][SharedBoardsName] = true
config := createBoardsConfig(*mmConfig, "", "")
mmConfig.PluginSettings.Plugins[server.PluginName] = make(map[string]interface{})
mmConfig.PluginSettings.Plugins[server.PluginName][server.SharedBoardsName] = true
config := server.CreateBoardsConfig(*mmConfig, "", "")
assert.Equal(t, true, config.EnablePublicSharedBoards)
})
@ -93,7 +95,7 @@ func TestSetConfiguration(t *testing.T) {
mmConfig := baseConfig
mmConfig.FeatureFlags = featureFlags
config := createBoardsConfig(*mmConfig, "", "")
config := server.CreateBoardsConfig(*mmConfig, "", "")
assert.Equal(t, "true", config.FeatureFlags["TestBoolFeature"])
assert.Equal(t, "test", config.FeatureFlags["TestFeature"])
@ -103,13 +105,10 @@ func TestSetConfiguration(t *testing.T) {
}
func TestServeHTTP(t *testing.T) {
th, tearDown := SetupTestHelper(t)
defer tearDown()
th := SetupTestHelperPluginMode(t)
defer th.TearDown()
b := &BoardsApp{
server: th.Server,
logger: mlog.CreateConsoleTestLogger(true, mlog.LvlError),
}
b := server.NewBoardsServiceForTest(th.Server, &FakePluginAdapter{}, nil, mlog.CreateConsoleTestLogger(true, mlog.LvlError))
assert := assert.New(t)
w := httptest.NewRecorder()

View File

@ -94,7 +94,7 @@ func (*FakePermissionPluginAPI) HasPermissionToChannel(userID string, channelID
return channelID == "valid-channel-id"
}
func getTestConfig() (*config.Configuration, error) {
func GetTestConfig() (*config.Configuration, error) {
dbType, connectionString, err := sqlstore.PrepareNewTestDatabase()
if err != nil {
return nil, err
@ -142,7 +142,7 @@ func newTestServer(singleUserToken string) *server.Server {
}
func newTestServerWithLicense(singleUserToken string, licenseType LicenseType) *server.Server {
cfg, err := getTestConfig()
cfg, err := GetTestConfig()
if err != nil {
panic(err)
}
@ -189,7 +189,7 @@ func newTestServerWithLicense(singleUserToken string, licenseType LicenseType) *
}
func NewTestServerPluginMode() *server.Server {
cfg, err := getTestConfig()
cfg, err := GetTestConfig()
if err != nil {
panic(err)
}
@ -225,7 +225,7 @@ func NewTestServerPluginMode() *server.Server {
}
func newTestServerLocalMode() *server.Server {
cfg, err := getTestConfig()
cfg, err := GetTestConfig()
if err != nil {
panic(err)
}

View File

@ -0,0 +1,101 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package integrationtests
import (
"testing"
"github.com/golang/mock/gomock"
"github.com/mattermost/focalboard/server/model"
"github.com/mattermost/focalboard/server/server"
"github.com/mattermost/focalboard/server/ws"
mockservicesapi "github.com/mattermost/focalboard/server/model/mocks"
mm_model "github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
"github.com/stretchr/testify/assert"
)
func TestConfigurationNullConfiguration(t *testing.T) {
th := SetupTestHelperPluginMode(t)
defer th.TearDown()
logger := mlog.CreateConsoleTestLogger(true, mlog.LvlError)
boardsApp := server.NewBoardsServiceForTest(th.Server, &FakePluginAdapter{}, nil, logger)
assert.NotNil(t, boardsApp.Config())
}
func TestOnConfigurationChange(t *testing.T) {
stringRef := ""
basePlugins := make(map[string]map[string]interface{})
basePlugins[server.PluginName] = make(map[string]interface{})
basePlugins[server.PluginName][server.SharedBoardsName] = true
baseFeatureFlags := &mm_model.FeatureFlags{
BoardsFeatureFlags: "Feature1-Feature2",
}
basePluginSettings := &mm_model.PluginSettings{
Directory: &stringRef,
Plugins: basePlugins,
}
intRef := 365
baseDataRetentionSettings := &mm_model.DataRetentionSettings{
BoardsRetentionDays: &intRef,
}
usernameRef := "username"
baseTeamSettings := &mm_model.TeamSettings{
TeammateNameDisplay: &usernameRef,
}
falseRef := false
basePrivacySettings := &mm_model.PrivacySettings{
ShowEmailAddress: &falseRef,
ShowFullName: &falseRef,
}
baseConfig := &mm_model.Config{
FeatureFlags: baseFeatureFlags,
PluginSettings: *basePluginSettings,
DataRetentionSettings: *baseDataRetentionSettings,
TeamSettings: *baseTeamSettings,
PrivacySettings: *basePrivacySettings,
}
t.Run("Test Load Plugin Success", func(t *testing.T) {
th := SetupTestHelperPluginMode(t)
defer th.TearDown()
ctrl := gomock.NewController(t)
api := mockservicesapi.NewMockServicesAPI(ctrl)
api.EXPECT().GetConfig().Return(baseConfig)
b := server.NewBoardsServiceForTest(th.Server, &FakePluginAdapter{}, api, mlog.CreateConsoleTestLogger(true, mlog.LvlError))
err := b.OnConfigurationChange()
assert.NoError(t, err)
assert.Equal(t, 1, count)
// make sure both App and Server got updated
assert.True(t, b.Config().EnablePublicSharedBoards)
assert.True(t, b.ClientConfig().EnablePublicSharedBoards)
assert.Equal(t, "true", b.Config().FeatureFlags["Feature1"])
assert.Equal(t, "true", b.Config().FeatureFlags["Feature2"])
assert.Equal(t, "", b.Config().FeatureFlags["Feature3"])
})
}
var count = 0
type FakePluginAdapter struct {
ws.PluginAdapter
}
func (c *FakePluginAdapter) BroadcastConfigChange(clientConfig model.ClientConfig) {
count++
}

View File

@ -7,8 +7,8 @@ import (
"errors"
"fmt"
"github.com/mattermost/focalboard/mattermost-plugin/server/boards"
"github.com/mattermost/focalboard/server/model"
"github.com/mattermost/focalboard/server/server"
mm_model "github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin"
@ -71,7 +71,7 @@ type boardsProduct struct {
preferencesService product.PreferencesService
hooksService product.HooksService
boardsApp *boards.BoardsApp
boardsApp *server.BoardsService
}
func newBoardsProduct(services map[product.ServiceKey]interface{}) (product.Product, error) {
@ -84,7 +84,7 @@ func newBoardsProduct(services map[product.ServiceKey]interface{}) (product.Prod
boardsProd.logger.Info("Creating boards service")
adapter := newServiceAPIAdapter(boardsProd)
boardsApp, err := boards.NewBoardsApp(adapter)
boardsApp, err := server.NewBoardsService(adapter)
if err != nil {
return nil, fmt.Errorf("failed to create Boards service: %w", err)
}
@ -92,7 +92,7 @@ func newBoardsProduct(services map[product.ServiceKey]interface{}) (product.Prod
boardsProd.boardsApp = boardsApp
// Add the Boards services API to the services map so other products can access Boards functionality.
boardsAPI := boards.NewBoardsServiceAPI(boardsApp)
boardsAPI := server.NewBoardsServiceAPI(boardsApp)
services[product.BoardsKey] = boardsAPI
return boardsProd, nil
@ -230,7 +230,7 @@ func (bp *boardsProduct) Start() error {
bp.logger.Info("Starting boards service")
adapter := newServiceAPIAdapter(bp)
boardsApp, err := boards.NewBoardsApp(adapter)
boardsApp, err := server.NewBoardsService(adapter)
if err != nil {
return fmt.Errorf("failed to create Boards service: %w", err)
}

View File

@ -6,5 +6,5 @@ package imports
import (
// Needed to ensure the init() method in the FocalBoard product is run.
// This file is copied to the mmserver imports package via makefile.
_ "github.com/mattermost/focalboard/mattermost-plugin/product"
_ "github.com/mattermost/focalboard/server/product"
)

View File

@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package boards
package server
import (
"fmt"
@ -10,7 +10,7 @@ import (
"github.com/mattermost/focalboard/server/auth"
"github.com/mattermost/focalboard/server/model"
"github.com/mattermost/focalboard/server/server"
"github.com/mattermost/focalboard/server/services/config"
"github.com/mattermost/focalboard/server/services/notify"
"github.com/mattermost/focalboard/server/services/permissions/mmpermissions"
"github.com/mattermost/focalboard/server/services/store"
@ -43,7 +43,7 @@ type BoardsEmbed struct {
ReadToken string `json:"readToken,omitempty"`
}
type BoardsApp struct {
type BoardsService struct {
// configurationLock synchronizes access to the configuration.
configurationLock sync.RWMutex
@ -51,14 +51,24 @@ type BoardsApp struct {
// setConfiguration for usage.
configuration *configuration
server *server.Server
server *Server
wsPluginAdapter ws.PluginAdapterInterface
servicesAPI model.ServicesAPI
logger mlog.LoggerIFace
}
func NewBoardsApp(api model.ServicesAPI) (*BoardsApp, error) {
func NewBoardsServiceForTest(server *Server, wsPluginAdapter ws.PluginAdapterInterface,
api model.ServicesAPI, logger mlog.LoggerIFace) *BoardsService {
return &BoardsService{
server: server,
wsPluginAdapter: wsPluginAdapter,
servicesAPI: api,
logger: logger,
}
}
func NewBoardsService(api model.ServicesAPI) (*BoardsService, error) {
mmconfig := api.GetConfig()
logger := api.GetLogger()
@ -67,7 +77,7 @@ func NewBoardsApp(api model.ServicesAPI) (*BoardsApp, error) {
baseURL = *mmconfig.ServiceSettings.SiteURL
}
serverID := api.GetDiagnosticID()
cfg := createBoardsConfig(*mmconfig, baseURL, serverID)
cfg := CreateBoardsConfig(*mmconfig, baseURL, serverID)
sqlDB, err := api.GetMasterDB()
if err != nil {
return nil, fmt.Errorf("cannot access database while initializing Boards: %w", err)
@ -92,7 +102,7 @@ func NewBoardsApp(api model.ServicesAPI) (*BoardsApp, error) {
if err != nil {
return nil, fmt.Errorf("error initializing the DB: %w", err)
}
if cfg.AuthMode == server.MattermostAuthMod {
if cfg.AuthMode == MattermostAuthMod {
layeredStore, err2 := mattermostauthlayer.New(cfg.DBType, sqlDB, db, logger, api, storeParams.TablePrefix)
if err2 != nil {
return nil, fmt.Errorf("error initializing the DB: %w", err2)
@ -128,7 +138,7 @@ func NewBoardsApp(api model.ServicesAPI) (*BoardsApp, error) {
notifyBackends = append(notifyBackends, subscriptionsBackend)
mentionsBackend.AddListener(subscriptionsBackend)
params := server.Params{
params := Params{
Cfg: cfg,
SingleUserToken: "",
DBStore: db,
@ -140,7 +150,7 @@ func NewBoardsApp(api model.ServicesAPI) (*BoardsApp, error) {
IsPlugin: true,
}
server, err := server.New(params)
server, err := New(params)
if err != nil {
return nil, fmt.Errorf("error initializing the server: %w", err)
}
@ -162,7 +172,7 @@ func NewBoardsApp(api model.ServicesAPI) (*BoardsApp, error) {
}
*/
return &BoardsApp{
return &BoardsService{
server: server,
wsPluginAdapter: wsPluginAdapter,
servicesAPI: api,
@ -170,7 +180,7 @@ func NewBoardsApp(api model.ServicesAPI) (*BoardsApp, error) {
}, nil
}
func (b *BoardsApp) Start() error {
func (b *BoardsService) Start() error {
if err := b.server.Start(); err != nil {
return fmt.Errorf("error starting Boards server: %w", err)
}
@ -182,7 +192,7 @@ func (b *BoardsApp) Start() error {
return nil
}
func (b *BoardsApp) Stop() error {
func (b *BoardsService) Stop() error {
return b.server.Shutdown()
}
@ -190,38 +200,46 @@ func (b *BoardsApp) Stop() error {
// These callbacks are called automatically by the suite server.
//
func (b *BoardsApp) MessageWillBePosted(_ *plugin.Context, post *mm_model.Post) (*mm_model.Post, string) {
func (b *BoardsService) MessageWillBePosted(_ *plugin.Context, post *mm_model.Post) (*mm_model.Post, string) {
return postWithBoardsEmbed(post), ""
}
func (b *BoardsApp) MessageWillBeUpdated(_ *plugin.Context, newPost, _ *mm_model.Post) (*mm_model.Post, string) {
func (b *BoardsService) MessageWillBeUpdated(_ *plugin.Context, newPost, _ *mm_model.Post) (*mm_model.Post, string) {
return postWithBoardsEmbed(newPost), ""
}
func (b *BoardsApp) OnWebSocketConnect(webConnID, userID string) {
func (b *BoardsService) OnWebSocketConnect(webConnID, userID string) {
b.wsPluginAdapter.OnWebSocketConnect(webConnID, userID)
}
func (b *BoardsApp) OnWebSocketDisconnect(webConnID, userID string) {
func (b *BoardsService) OnWebSocketDisconnect(webConnID, userID string) {
b.wsPluginAdapter.OnWebSocketDisconnect(webConnID, userID)
}
func (b *BoardsApp) WebSocketMessageHasBeenPosted(webConnID, userID string, req *mm_model.WebSocketRequest) {
func (b *BoardsService) WebSocketMessageHasBeenPosted(webConnID, userID string, req *mm_model.WebSocketRequest) {
b.wsPluginAdapter.WebSocketMessageHasBeenPosted(webConnID, userID, req)
}
func (b *BoardsApp) OnPluginClusterEvent(_ *plugin.Context, ev mm_model.PluginClusterEvent) {
func (b *BoardsService) OnPluginClusterEvent(_ *plugin.Context, ev mm_model.PluginClusterEvent) {
b.wsPluginAdapter.HandleClusterEvent(ev)
}
func (b *BoardsApp) OnCloudLimitsUpdated(limits *mm_model.ProductLimits) {
func (b *BoardsService) OnCloudLimitsUpdated(limits *mm_model.ProductLimits) {
if err := b.server.App().SetCloudLimits(limits); err != nil {
b.logger.Error("Error setting the cloud limits for Boards", mlog.Err(err))
}
}
func (b *BoardsService) Config() *config.Configuration {
return b.server.Config()
}
func (b *BoardsService) ClientConfig() *model.ClientConfig {
return b.server.App().GetClientConfig()
}
// ServeHTTP demonstrates a plugin that handles HTTP requests by greeting the world.
func (b *BoardsApp) ServeHTTP(_ *plugin.Context, w http.ResponseWriter, r *http.Request) {
func (b *BoardsService) ServeHTTP(_ *plugin.Context, w http.ResponseWriter, r *http.Request) {
router := b.server.GetRootRouter()
router.ServeHTTP(w, r)
}

View File

@ -1,4 +1,4 @@
package boards
package server
import (
"github.com/mattermost/focalboard/server/app"
@ -13,7 +13,7 @@ type boardsServiceAPI struct {
app *app.App
}
func NewBoardsServiceAPI(app *BoardsApp) *boardsServiceAPI {
func NewBoardsServiceAPI(app *BoardsService) *boardsServiceAPI {
return &boardsServiceAPI{
app: app.server.App(),
}

View File

@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package boards
package server
import (
"math"
@ -15,7 +15,7 @@ import (
const defaultS3Timeout = 60 * 1000 // 60 seconds
func createBoardsConfig(mmconfig mm_model.Config, baseURL string, serverID string) *config.Configuration {
func CreateBoardsConfig(mmconfig mm_model.Config, baseURL string, serverID string) *config.Configuration {
filesS3Config := config.AmazonS3Config{}
if mmconfig.FileSettings.AmazonS3AccessKeyId != nil {
filesS3Config.AccessKeyID = *mmconfig.FileSettings.AmazonS3AccessKeyId

View File

@ -1,4 +1,4 @@
package boards
package server
import (
"reflect"
@ -29,7 +29,7 @@ func (c *configuration) Clone() *configuration {
// getConfiguration retrieves the active configuration under lock, making it safe to use
// concurrently. The active configuration may change underneath the client of this method, but
// the struct returned by this API call is considered immutable.
func (b *BoardsApp) getConfiguration() *configuration {
func (b *BoardsService) getConfiguration() *configuration {
b.configurationLock.RLock()
defer b.configurationLock.RUnlock()
@ -49,7 +49,7 @@ func (b *BoardsApp) getConfiguration() *configuration {
// This method panics if setConfiguration is called with the existing configuration. This almost
// certainly means that the configuration was modified without being cloned and may result in
// an unsafe access.
func (b *BoardsApp) setConfiguration(configuration *configuration) {
func (b *BoardsService) setConfiguration(configuration *configuration) {
b.configurationLock.Lock()
defer b.configurationLock.Unlock()
@ -68,7 +68,7 @@ func (b *BoardsApp) setConfiguration(configuration *configuration) {
}
// OnConfigurationChange is invoked when configuration changes may have been made.
func (b *BoardsApp) OnConfigurationChange() error {
func (b *BoardsService) OnConfigurationChange() error {
// Have we been setup by OnActivate?
if b.server == nil {
return nil

View File

@ -1,6 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package boards
package server
import (
"errors"
@ -9,7 +9,7 @@ import (
var ErrInsufficientLicense = errors.New("appropriate license required")
func (b *BoardsApp) RunDataRetention(nowTime, batchSize int64) (int64, error) {
func (b *BoardsService) RunDataRetention(nowTime, batchSize int64) (int64, error) {
b.logger.Debug("Boards RunDataRetention")
license := b.server.Store().GetLicense()
if license == nil || !(*license.Features.DataRetention) {

View File

@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package boards
package server
import (
"os"
@ -9,7 +9,6 @@ import (
"time"
"github.com/golang/mock/gomock"
"github.com/mattermost/focalboard/server/server"
"github.com/mattermost/focalboard/server/services/config"
"github.com/mattermost/focalboard/server/services/permissions/localpermissions"
"github.com/mattermost/focalboard/server/services/store/mockstore"
@ -20,7 +19,7 @@ import (
)
type TestHelperMockStore struct {
Server *server.Server
Server *Server
Store *mockstore.MockStore
}
@ -44,7 +43,7 @@ func SetupTestHelperMockStore(t *testing.T) (*TestHelperMockStore, func()) {
return th, tearDown
}
func newTestServerMock(mockStore *mockstore.MockStore) *server.Server {
func newTestServerMock(mockStore *mockstore.MockStore) *Server {
config := &config.Configuration{
EnableDataRetention: false,
DataRetentionDays: 10,
@ -62,7 +61,7 @@ func newTestServerMock(mockStore *mockstore.MockStore) *server.Server {
permissionsService := localpermissions.New(mockStore, logger)
srv, err := server.New(server.Params{
srv, err := New(Params{
Cfg: config,
DBStore: mockStore,
Logger: logger,
@ -79,7 +78,7 @@ func TestRunDataRetention(t *testing.T) {
th, tearDown := SetupTestHelperMockStore(t)
defer tearDown()
b := &BoardsApp{
b := &BoardsService{
server: th.Server,
logger: mlog.CreateConsoleTestLogger(true, mlog.LvlError),
}

View File

@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package boards
package server
import (
"errors"

View File

@ -1,4 +1,4 @@
package boards
package server
import (
"fmt"

View File

@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package boards
package server
import (
"encoding/json"