From 2ba91e43b65dd0b7e8abd4773155381345608537 Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Tue, 17 Oct 2023 11:55:41 -0300 Subject: [PATCH] Remove support for unused product interfaces (#24965) We no longer rely on commands and hooks for products, so simplify this code. --- server/channels/app/app_iface.go | 5 +- server/channels/app/channels.go | 30 --- server/channels/app/command.go | 11 +- .../app/opentracing/opentracing_layer.go | 40 ---- server/channels/app/plugin_commands.go | 121 +----------- server/channels/app/plugin_commands_test.go | 184 ------------------ server/channels/app/server.go | 4 - server/channels/product/api.go | 8 - server/channels/product/hooks.go | 79 -------- server/channels/product/service.go | 1 - .../services/telemetry/mocks/ServerIface.go | 18 -- .../platform/services/telemetry/telemetry.go | 15 -- .../services/telemetry/telemetry_test.go | 2 - 13 files changed, 3 insertions(+), 515 deletions(-) delete mode 100644 server/channels/product/hooks.go diff --git a/server/channels/app/app_iface.go b/server/channels/app/app_iface.go index b6c7dba572..9eccd5b776 100644 --- a/server/channels/app/app_iface.go +++ b/server/channels/app/app_iface.go @@ -26,7 +26,6 @@ import ( "github.com/mattermost/mattermost/server/public/shared/timezones" "github.com/mattermost/mattermost/server/v8/channels/app/platform" "github.com/mattermost/mattermost/server/v8/channels/audit" - "github.com/mattermost/mattermost/server/v8/channels/product" "github.com/mattermost/mattermost/server/v8/channels/store" "github.com/mattermost/mattermost/server/v8/einterfaces" "github.com/mattermost/mattermost/server/v8/platform/services/httpservice" @@ -76,7 +75,7 @@ type AppIface interface { // overriding attributes set by the user's login provider; otherwise, the name of the offending // field is returned. CheckProviderAttributes(c *request.Context, user *model.User, patch *model.UserPatch) string - // CommandsForTeam returns all the plugin and product commands for the given team. + // CommandsForTeam returns all the plugin commands for the given team. CommandsForTeam(teamID string) []*model.Command // ComputeLastAccessibleFileTime updates cache with CreateAt time of the last accessible file as per the cloud plan's limit. // Use GetLastAccessibleFileTime() to access the result. @@ -870,7 +869,6 @@ type AppIface interface { HasPermissionToTeam(c request.CTX, askingUserId string, teamID string, permission *model.Permission) bool HasPermissionToUser(askingUserId string, userID string) bool HasSharedChannel(channelID string) (bool, error) - HooksManager() *product.HooksManager ImageProxy() *imageproxy.ImageProxy ImageProxyAdder() func(string) string ImageProxyRemover() (f func(string) string) @@ -964,7 +962,6 @@ type AppIface interface { RegenerateOAuthAppSecret(app *model.OAuthApp) (*model.OAuthApp, *model.AppError) RegenerateTeamInviteId(teamID string) (*model.Team, *model.AppError) RegisterPluginCommand(pluginID string, command *model.Command) error - RegisterProductCommand(ProductID string, command *model.Command) error ReloadConfig() error RemoveAllDeactivatedMembersFromChannel(c request.CTX, channel *model.Channel) *model.AppError RemoveChannelsFromRetentionPolicy(policyID string, channelIDs []string) *model.AppError diff --git a/server/channels/app/channels.go b/server/channels/app/channels.go index ed8763ff6f..a4721e1c4e 100644 --- a/server/channels/app/channels.go +++ b/server/channels/app/channels.go @@ -51,9 +51,6 @@ type Channels struct { pluginConfigListenerID string pluginClusterLeaderListenerID string - productCommandsLock sync.RWMutex - productCommands []*ProductCommand - imageProxy *imageproxy.ImageProxy // cached counts that are used during notice condition validation @@ -239,10 +236,6 @@ func NewChannels(services map[product.ServiceKey]any) (*Channels, error) { app: &App{ch: ch}, } - services[product.HooksKey] = &hooksService{ - ch: ch, - } - services[product.UserKey] = &App{ch: ch} services[product.PreferencesKey] = &preferencesServiceWrapper{ @@ -334,28 +327,10 @@ func (ch *Channels) RequestTrialLicense(requesterID string, users int, termsAcce receiveEmailsAccepted) } -func (a *App) HooksManager() *product.HooksManager { - return a.ch.srv.hooksManager -} - -// Ensure hooksService implements `product.HooksService` -var _ product.HooksService = (*hooksService)(nil) - -type hooksService struct { - ch *Channels -} - -func (s *hooksService) RegisterHooks(productID string, hooks any) error { - return s.ch.srv.hooksManager.AddProduct(productID, hooks) -} - func (ch *Channels) RunMultiHook(hookRunnerFunc func(hooks plugin.Hooks) bool, hookId int) { if env := ch.GetPluginsEnvironment(); env != nil { env.RunMultiPluginHook(hookRunnerFunc, hookId) } - - // run hook for the products - ch.srv.hooksManager.RunMultiHook(hookRunnerFunc, hookId) } func (ch *Channels) HooksForPluginOrProduct(id string) (plugin.Hooks, error) { @@ -369,10 +344,5 @@ func (ch *Channels) HooksForPluginOrProduct(id string) (plugin.Hooks, error) { } } - hooks = ch.srv.hooksManager.HooksForProduct(id) - if hooks != nil { - return hooks, nil - } - return nil, fmt.Errorf("could not find hooks for id %s", id) } diff --git a/server/channels/app/command.go b/server/channels/app/command.go index 6693d907a7..6af333ced3 100644 --- a/server/channels/app/command.go +++ b/server/channels/app/command.go @@ -202,7 +202,7 @@ func (a *App) ExecuteCommand(c *request.Context, args *model.CommandArgs) (*mode args.TriggerId = triggerId - // Plugins can override built in, custom, and product commands + // Plugins can override built in and custom commands cmd, response, appErr := a.tryExecutePluginCommand(c, args) if appErr != nil { return nil, appErr @@ -211,15 +211,6 @@ func (a *App) ExecuteCommand(c *request.Context, args *model.CommandArgs) (*mode return a.HandleCommandResponse(c, cmd, args, response, true) } - // Products can override built in and custom commands - cmd, response, appErr = a.tryExecuteProductCommand(c, args) - if appErr != nil { - return nil, appErr - } else if cmd != nil && response != nil { - response.TriggerId = clientTriggerId - return a.HandleCommandResponse(c, cmd, args, response, true) - } - // Custom commands can override built ins cmd, response, appErr = a.tryExecuteCustomCommand(c, args, trigger, message) if appErr != nil { diff --git a/server/channels/app/opentracing/opentracing_layer.go b/server/channels/app/opentracing/opentracing_layer.go index de06fc384e..c95256e449 100644 --- a/server/channels/app/opentracing/opentracing_layer.go +++ b/server/channels/app/opentracing/opentracing_layer.go @@ -27,7 +27,6 @@ import ( "github.com/mattermost/mattermost/server/v8/channels/app" "github.com/mattermost/mattermost/server/v8/channels/app/platform" "github.com/mattermost/mattermost/server/v8/channels/audit" - "github.com/mattermost/mattermost/server/v8/channels/product" "github.com/mattermost/mattermost/server/v8/channels/store" "github.com/mattermost/mattermost/server/v8/einterfaces" "github.com/mattermost/mattermost/server/v8/platform/services/httpservice" @@ -11546,23 +11545,6 @@ func (a *OpenTracingAppLayer) HasSharedChannel(channelID string) (bool, error) { return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) HooksManager() *product.HooksManager { - origCtx := a.ctx - span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.HooksManager") - - a.ctx = newCtx - a.app.Srv().Store().SetContext(newCtx) - defer func() { - a.app.Srv().Store().SetContext(origCtx) - a.ctx = origCtx - }() - - defer span.Finish() - resultVar0 := a.app.HooksManager() - - return resultVar0 -} - func (a *OpenTracingAppLayer) HubRegister(webConn *platform.WebConn) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.HubRegister") @@ -13690,28 +13672,6 @@ func (a *OpenTracingAppLayer) RegisterPluginCommand(pluginID string, command *mo return resultVar0 } -func (a *OpenTracingAppLayer) RegisterProductCommand(ProductID string, command *model.Command) error { - origCtx := a.ctx - span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.RegisterProductCommand") - - a.ctx = newCtx - a.app.Srv().Store().SetContext(newCtx) - defer func() { - a.app.Srv().Store().SetContext(origCtx) - a.ctx = origCtx - }() - - defer span.Finish() - resultVar0 := a.app.RegisterProductCommand(ProductID, command) - - if resultVar0 != nil { - span.LogFields(spanlog.Error(resultVar0)) - ext.Error.Set(span, true) - } - - return resultVar0 -} - func (a *OpenTracingAppLayer) ReloadConfig() error { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.ReloadConfig") diff --git a/server/channels/app/plugin_commands.go b/server/channels/app/plugin_commands.go index 24c64e2c80..00998fa5d6 100644 --- a/server/channels/app/plugin_commands.go +++ b/server/channels/app/plugin_commands.go @@ -102,7 +102,7 @@ func (ch *Channels) unregisterPluginCommands(pluginID string) { ch.pluginCommands = remaining } -// CommandsForTeam returns all the plugin and product commands for the given team. +// CommandsForTeam returns all the plugin commands for the given team. func (a *App) CommandsForTeam(teamID string) []*model.Command { var commands []*model.Command @@ -114,13 +114,6 @@ func (a *App) CommandsForTeam(teamID string) []*model.Command { } } - a.ch.productCommandsLock.RLock() - defer a.ch.productCommandsLock.RUnlock() - for _, pc := range a.ch.productCommands { - if pc.Command.TeamId == "" || pc.Command.TeamId == teamID { - commands = append(commands, pc.Command) - } - } return commands } @@ -183,115 +176,3 @@ func (a *App) tryExecutePluginCommand(c request.CTX, args *model.CommandArgs) (* return matched.Command, response, appErr } - -// Support for slash commands to MPA -// -// Key differences/points with plugin commands: -// - There's no need of health checks or unregisterProductCommands on products, they are compiled and assumed as active server side -// - HooksForProduct still returns a plugin.Hooks struct, it might make sense to improve the name/package -// - Plugin code had a check for a plugin crash after a command was executed, that has been omitted for products - -type ProductCommand struct { - Command *model.Command - ProductID string -} - -func (a *App) RegisterProductCommand(ProductID string, command *model.Command) error { - if command.Trigger == "" { - return errors.New("invalid command") - } - if command.AutocompleteData != nil { - if err := command.AutocompleteData.IsValid(); err != nil { - return errors.Wrap(err, "invalid autocomplete data in command") - } - } - - if command.AutocompleteData == nil { - command.AutocompleteData = model.NewAutocompleteData(command.Trigger, command.AutoCompleteHint, command.AutoCompleteDesc) - } else { - baseURL, err := url.Parse("/plugins/" + ProductID) - if err != nil { - return errors.Wrapf(err, "Can't parse url %s", "/plugins/"+ProductID) - } - err = command.AutocompleteData.UpdateRelativeURLsForPluginCommands(baseURL) - if err != nil { - return errors.Wrap(err, "Can't update relative urls for plugin commands") - } - } - - command = &model.Command{ - Trigger: strings.ToLower(command.Trigger), - TeamId: command.TeamId, - AutoComplete: command.AutoComplete, - AutoCompleteDesc: command.AutoCompleteDesc, - AutoCompleteHint: command.AutoCompleteHint, - DisplayName: command.DisplayName, - AutocompleteData: command.AutocompleteData, - AutocompleteIconData: command.AutocompleteIconData, - } - - a.ch.productCommandsLock.Lock() - defer a.ch.productCommandsLock.Unlock() - - for _, pc := range a.ch.productCommands { - if pc.Command.Trigger == command.Trigger && pc.Command.TeamId == command.TeamId { - if pc.ProductID == ProductID { - pc.Command = command - return nil - } - } - } - - a.ch.productCommands = append(a.ch.productCommands, &ProductCommand{ - Command: command, - ProductID: ProductID, - }) - return nil -} - -// tryExecuteProductCommand attempts to run a command provided by a product based on the given arguments. If no such -// command can be found, returns nil for all arguments. -func (a *App) tryExecuteProductCommand(c request.CTX, args *model.CommandArgs) (*model.Command, *model.CommandResponse, *model.AppError) { - parts := strings.Split(args.Command, " ") - trigger := parts[0][1:] - trigger = strings.ToLower(trigger) - - var matched *ProductCommand - a.ch.productCommandsLock.RLock() - for _, pc := range a.ch.productCommands { - if (pc.Command.TeamId == "" || pc.Command.TeamId == args.TeamId) && pc.Command.Trigger == trigger { - matched = pc - break - } - } - a.ch.productCommandsLock.RUnlock() - if matched == nil { - return nil, nil, nil - } - - // The type returned is still plugin.Hooks, could make sense in the future to move Hooks - // to another package or change the abstraction - productHooks := a.HooksManager().HooksForProduct(matched.ProductID) - if productHooks == nil { - return matched.Command, nil, model.NewAppError("ExecutePropductCommand", "model.plugin_command.error.app_error", nil, "", http.StatusInternalServerError) - } - - for username, userID := range a.MentionsToTeamMembers(c, args.Command, args.TeamId) { - args.AddUserMention(username, userID) - } - - for channelName, channelID := range a.MentionsToPublicChannels(c, args.Command, args.TeamId) { - args.AddChannelMention(channelName, channelID) - } - - response, appErr := productHooks.ExecuteCommand(pluginContext(c), args) - - // This is a response from the product, which may set an incorrect status code; - // e.g setting a status code of 0 will crash the server. So we always bucket everything under 500. - if appErr != nil && (appErr.StatusCode < 100 || appErr.StatusCode > 999) { - mlog.Warn("Invalid status code returned from plugin. Converting to internal server error.", mlog.String("plugin_id", matched.ProductID), mlog.Int("status_code", appErr.StatusCode)) - appErr.StatusCode = http.StatusInternalServerError - } - - return matched.Command, response, appErr -} diff --git a/server/channels/app/plugin_commands_test.go b/server/channels/app/plugin_commands_test.go index ab330ebd38..5b223bdf95 100644 --- a/server/channels/app/plugin_commands_test.go +++ b/server/channels/app/plugin_commands_test.go @@ -7,13 +7,10 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/mattermost/mattermost/server/public/model" - "github.com/mattermost/mattermost/server/public/plugin" "github.com/mattermost/mattermost/server/public/shared/i18n" - "github.com/mattermost/mattermost/server/v8/channels/product" ) func TestPluginCommand(t *testing.T) { @@ -441,184 +438,3 @@ func TestPluginCommand(t *testing.T) { require.Equal(t, 500, err.StatusCode) }) } - -// Test Product with the minimum code needed to handle -// hooksmanager and slash commands -type TProduct struct { - hooksService product.HooksService -} - -func newTProduct(m map[product.ServiceKey]any) (product.Product, error) { - return &TProduct{ - hooksService: m[product.HooksKey].(product.HooksService), - }, nil -} -func (p *TProduct) Start() error { - p.hooksService.RegisterHooks("productT", p) - return nil -} -func (p *TProduct) Stop() error { return nil } -func (p *TProduct) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) { - return &model.CommandResponse{Text: "product slash command called"}, nil -} - -func TestProductCommands(t *testing.T) { - products := map[string]product.Manifest{ - "productT": { - Initializer: newTProduct, - Dependencies: map[product.ServiceKey]struct{}{}, - }, - } - - t.Run("Execute product command", func(t *testing.T) { - th := Setup(t, SkipProductsInitialization()).InitBasic() - defer th.TearDown() - // Server hijack. - // This must be done in a cleaner way. - th.Server.skipProductsInit = false - th.Server.initializeProducts(products, th.Server.services) - th.Server.products["productT"].Start() - require.Len(t, th.Server.products, 2) // 1 product + channels - - err := th.App.RegisterProductCommand("productT", &model.Command{ - TeamId: th.BasicTeam.Id, - Trigger: "product", - DisplayName: "Product Command", - AutoComplete: true, - AutoCompleteDesc: "autocomplete", - }) - require.NoError(t, err) - - resp, err2 := th.App.ExecuteCommand(th.Context, &model.CommandArgs{ - TeamId: th.BasicTeam.Id, - ChannelId: th.BasicChannel.Id, - UserId: th.BasicUser.Id, - Command: "/product", - }) - require.Nil(t, err2) - require.NotNil(t, resp) - assert.Equal(t, "product slash command called", resp.Text) - }) - - t.Run("Product commands can override builtin commands", func(t *testing.T) { - th := Setup(t, SkipProductsInitialization()).InitBasic() - defer th.TearDown() - // Server hijack. - // This must be done in a cleaner way. - th.Server.skipProductsInit = false - th.Server.initializeProducts(products, th.Server.services) - th.Server.products["productT"].Start() - require.Len(t, th.Server.products, 2) // 1 product + channels - - err := th.App.RegisterProductCommand("productT", &model.Command{ - TeamId: th.BasicTeam.Id, - Trigger: "away", - DisplayName: "Product Command", - AutoComplete: true, - AutoCompleteDesc: "autocomplete", - }) - require.NoError(t, err) - - resp, err2 := th.App.ExecuteCommand(th.Context, &model.CommandArgs{ - TeamId: th.BasicTeam.Id, - ChannelId: th.BasicChannel.Id, - UserId: th.BasicUser.Id, - Command: "/away", - }) - require.Nil(t, err2) - require.NotNil(t, resp) - assert.Equal(t, "product slash command called", resp.Text) - }) - - t.Run("Plugin commands can override product commands", func(t *testing.T) { - th := Setup(t, SkipProductsInitialization()).InitBasic() - defer th.TearDown() - - th.App.UpdateConfig(func(cfg *model.Config) { - cfg.PluginSettings.Plugins["testloadpluginconfig"] = map[string]any{ - "TeamId": th.BasicTeam.Id, - } - }) - - tearDown, _, activationErrors := SetAppEnvironmentWithPlugins(t, []string{` - package main - - import ( - "github.com/mattermost/mattermost/server/public/plugin" - "github.com/mattermost/mattermost/server/public/model" - ) - - type configuration struct { - TeamId string - } - - type MyPlugin struct { - plugin.MattermostPlugin - - configuration configuration - } - - func (p *MyPlugin) OnConfigurationChange() error { - if err := p.API.LoadPluginConfiguration(&p.configuration); err != nil { - return err - } - - return nil - } - - func (p *MyPlugin) OnActivate() error { - err := p.API.RegisterCommand(&model.Command{ - TeamId: p.configuration.TeamId, - Trigger: "triggername", - DisplayName: "Plugin Command", - AutoComplete: true, - AutoCompleteDesc: "autocomplete", - }) - if err != nil { - p.API.LogError("error", "err", err) - } - - return err - } - - func (p *MyPlugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) { - return &model.CommandResponse{ - Text: "plugin slash command called", - }, nil - } - - func main() { - plugin.ClientMain(&MyPlugin{}) - } - `}, th.App, th.NewPluginAPI) - defer tearDown() - require.Len(t, activationErrors, 1) - require.Nil(t, nil, activationErrors[0]) - - // Server hijack. - // This must be done in a cleaner way. - th.Server.skipProductsInit = false - th.Server.initializeProducts(products, th.Server.services) - th.Server.products["productT"].Start() - require.Len(t, th.Server.products, 2) // 1 product + channels - - err := th.App.RegisterProductCommand("productT", &model.Command{ - TeamId: th.BasicTeam.Id, - Trigger: "triggername", - DisplayName: "Product Command", - AutoComplete: true, - AutoCompleteDesc: "autocomplete", - }) - require.NoError(t, err) - - resp, err2 := th.App.ExecuteCommand(th.Context, &model.CommandArgs{ - TeamId: th.BasicTeam.Id, - ChannelId: th.BasicChannel.Id, - UserId: th.BasicUser.Id, - Command: "/triggername", - }) - require.Nil(t, err2) - require.NotNil(t, resp) - assert.Equal(t, "plugin slash command called", resp.Text) - }) -} diff --git a/server/channels/app/server.go b/server/channels/app/server.go index 6d4b43e07c..c8f951d70b 100644 --- a/server/channels/app/server.go +++ b/server/channels/app/server.go @@ -149,8 +149,6 @@ type Server struct { products map[string]product.Product services map[product.ServiceKey]any - - hooksManager *product.HooksManager } func (s *Server) Store() store.Store { @@ -246,8 +244,6 @@ func NewServer(options ...Option) (*Server, error) { return nil, errors.Wrapf(err, "unable to create teams service") } - s.hooksManager = product.NewHooksManager(s.GetMetrics()) - // ensure app implements `product.UserService` var _ product.UserService = (*App)(nil) diff --git a/server/channels/product/api.go b/server/channels/product/api.go index 2614f4f022..6552429c8d 100644 --- a/server/channels/product/api.go +++ b/server/channels/product/api.go @@ -226,14 +226,6 @@ type FrontendService interface { OpenInteractiveDialog(dialog model.OpenDialogRequest) *model.AppError } -// CommandService is the API for interacting with front end. -// -// The service shall be registered via app.CommandKey service key. -type CommandService interface { - ExecuteCommand(c request.CTX, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) - RegisterProductCommand(productID string, command *model.Command) error -} - // ThreadsService is the API for interacting with threads anywhere. // // The service shall be registered via app.ThreadsKey service key. diff --git a/server/channels/product/hooks.go b/server/channels/product/hooks.go deleted file mode 100644 index f0e82c1b87..0000000000 --- a/server/channels/product/hooks.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -package product - -import ( - "sync" - "time" - - "github.com/mattermost/mattermost/server/public/plugin" - "github.com/mattermost/mattermost/server/v8/einterfaces" -) - -type HooksManager struct { - registeredProducts sync.Map - metrics einterfaces.MetricsInterface -} - -func NewHooksManager(metrics einterfaces.MetricsInterface) *HooksManager { - return &HooksManager{ - metrics: metrics, - } -} - -func (m *HooksManager) AddProduct(productID string, hooks any) error { - prod, err := plugin.NewAdapter(hooks) - if err != nil { - return err - } - - rp := &plugin.RegisteredProduct{ - ProductID: productID, - Adapter: prod, - } - - m.registeredProducts.Store(productID, rp) - - return nil -} - -func (m *HooksManager) RemoveProduct(productID string) { - m.registeredProducts.Delete(productID) -} - -func (m *HooksManager) RunMultiHook(hookRunnerFunc func(hooks plugin.Hooks) bool, hookId int) { - startTime := time.Now() - - m.registeredProducts.Range(func(key, value any) bool { - rp := value.(*plugin.RegisteredProduct) - - if !rp.Implements(hookId) { - return true - } - - hookStartTime := time.Now() - result := hookRunnerFunc(rp.Adapter) - - if m.metrics != nil { - elapsedTime := float64(time.Since(hookStartTime)) / float64(time.Second) - m.metrics.ObservePluginMultiHookIterationDuration(rp.ProductID, elapsedTime) - } - - return result - }) - - if m.metrics != nil { - elapsedTime := float64(time.Since(startTime)) / float64(time.Second) - m.metrics.ObservePluginMultiHookDuration(elapsedTime) - } -} - -func (m *HooksManager) HooksForProduct(id string) plugin.Hooks { - if value, ok := m.registeredProducts.Load(id); ok { - rp := value.(*plugin.RegisteredProduct) - return rp.Adapter - } - - return nil -} diff --git a/server/channels/product/service.go b/server/channels/product/service.go index 5afca5668e..57088b8854 100644 --- a/server/channels/product/service.go +++ b/server/channels/product/service.go @@ -21,7 +21,6 @@ const ( RouterKey ServiceKey = "router" BotKey ServiceKey = "bot" LogKey ServiceKey = "log" - HooksKey ServiceKey = "hooks" KVStoreKey ServiceKey = "kvstore" StoreKey ServiceKey = "storekey" SystemKey ServiceKey = "systemkey" diff --git a/server/platform/services/telemetry/mocks/ServerIface.go b/server/platform/services/telemetry/mocks/ServerIface.go index 98e48cc9ca..c2185f8fbd 100644 --- a/server/platform/services/telemetry/mocks/ServerIface.go +++ b/server/platform/services/telemetry/mocks/ServerIface.go @@ -13,8 +13,6 @@ import ( model "github.com/mattermost/mattermost/server/public/model" plugin "github.com/mattermost/mattermost/server/public/plugin" - - product "github.com/mattermost/mattermost/server/v8/channels/product" ) // ServerIface is an autogenerated mock type for the ServerIface type @@ -126,22 +124,6 @@ func (_m *ServerIface) HTTPService() httpservice.HTTPService { return r0 } -// HooksManager provides a mock function with given fields: -func (_m *ServerIface) HooksManager() *product.HooksManager { - ret := _m.Called() - - var r0 *product.HooksManager - if rf, ok := ret.Get(0).(func() *product.HooksManager); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*product.HooksManager) - } - } - - return r0 -} - // IsLeader provides a mock function with given fields: func (_m *ServerIface) IsLeader() bool { ret := _m.Called() diff --git a/server/platform/services/telemetry/telemetry.go b/server/platform/services/telemetry/telemetry.go index 6369f97a0f..a3ac3fdd8f 100644 --- a/server/platform/services/telemetry/telemetry.go +++ b/server/platform/services/telemetry/telemetry.go @@ -17,7 +17,6 @@ import ( "github.com/mattermost/mattermost/server/public/model" "github.com/mattermost/mattermost/server/public/plugin" "github.com/mattermost/mattermost/server/public/shared/mlog" - "github.com/mattermost/mattermost/server/v8/channels/product" "github.com/mattermost/mattermost/server/v8/channels/store" "github.com/mattermost/mattermost/server/v8/channels/utils" "github.com/mattermost/mattermost/server/v8/platform/services/httpservice" @@ -102,7 +101,6 @@ type ServerIface interface { License() *model.License GetRoleByName(context.Context, string) (*model.Role, *model.AppError) GetSchemes(string, int, int) ([]*model.Scheme, *model.AppError) - HooksManager() *product.HooksManager } type TelemetryService struct { @@ -199,7 +197,6 @@ func (ts *TelemetryService) sendDailyTelemetry(override bool) { ts.trackGroups() ts.trackChannelModeration() ts.trackWarnMetrics() - ts.trackProducts() } } @@ -987,18 +984,6 @@ func (ts *TelemetryService) trackPlugins() { }, plugin.OnSendDailyTelemetryID) } -func (ts *TelemetryService) trackProducts() { - hm := ts.srv.HooksManager() - if hm == nil { - return - } - - hm.RunMultiHook(func(hooks plugin.Hooks) bool { - hooks.OnSendDailyTelemetry() - return true - }, plugin.OnSendDailyTelemetryID) -} - func (ts *TelemetryService) trackServer() { data := map[string]any{ "edition": model.BuildEnterpriseReady, diff --git a/server/platform/services/telemetry/telemetry_test.go b/server/platform/services/telemetry/telemetry_test.go index fb08fe55dd..b18307a569 100644 --- a/server/platform/services/telemetry/telemetry_test.go +++ b/server/platform/services/telemetry/telemetry_test.go @@ -24,7 +24,6 @@ import ( "github.com/mattermost/mattermost/server/public/plugin" "github.com/mattermost/mattermost/server/public/plugin/plugintest" "github.com/mattermost/mattermost/server/public/shared/mlog" - "github.com/mattermost/mattermost/server/v8/channels/product" storeMocks "github.com/mattermost/mattermost/server/v8/channels/store/storetest/mocks" "github.com/mattermost/mattermost/server/v8/config" "github.com/mattermost/mattermost/server/v8/platform/services/httpservice" @@ -189,7 +188,6 @@ func initializeMocks(cfg *model.Config, cloudLicense bool) (*mocks.ServerIface, serverIfaceMock.On("GetRoleByName", context.Background(), "channel_guest").Return(&model.Role{Permissions: []string{"cg-test1", "cg-test2"}}, nil) serverIfaceMock.On("GetSchemes", "team", 0, 100).Return([]*model.Scheme{}, nil) serverIfaceMock.On("HTTPService").Return(httpservice.MakeHTTPService(configService)) - serverIfaceMock.On("HooksManager").Return(product.NewHooksManager(nil)) storeMock := &storeMocks.Store{} storeMock.On("GetDbVersion", false).Return("5.24.0", nil)