diff --git a/server/channels/app/channel.go b/server/channels/app/channel.go index 43023cfa8e..1cb9067396 100644 --- a/server/channels/app/channel.go +++ b/server/channels/app/channel.go @@ -294,7 +294,7 @@ func (a *App) CreateChannel(c request.CTX, channel *model.Channel, addMember boo a.Srv().Go(func() { pluginContext := pluginContext(c) - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.ChannelHasBeenCreated(pluginContext, sc) return true }, plugin.ChannelHasBeenCreatedID) @@ -378,7 +378,7 @@ func (a *App) handleCreationEvent(c request.CTX, userID, otherUserID string, cha a.Srv().Go(func() { pluginContext := pluginContext(c) - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.ChannelHasBeenCreated(pluginContext, channel) return true }, plugin.ChannelHasBeenCreatedID) @@ -600,7 +600,7 @@ func (a *App) createGroupChannel(c request.CTX, userIDs []string) (*model.Channe a.Srv().Go(func() { pluginContext := pluginContext(c) - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.ChannelHasBeenCreated(pluginContext, channel) return true }, plugin.ChannelHasBeenCreatedID) @@ -1679,7 +1679,7 @@ func (a *App) AddChannelMember(c request.CTX, userID string, channel *model.Chan a.Srv().Go(func() { pluginContext := pluginContext(c) - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.UserHasJoinedChannel(pluginContext, cm, userRequestor) return true }, plugin.UserHasJoinedChannelID) @@ -2284,7 +2284,7 @@ func (a *App) JoinChannel(c request.CTX, channel *model.Channel, userID string) a.Srv().Go(func() { pluginContext := pluginContext(c) - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.UserHasJoinedChannel(pluginContext, cm, nil) return true }, plugin.UserHasJoinedChannelID) @@ -2598,7 +2598,7 @@ func (a *App) removeUserFromChannel(c request.CTX, userIDToRemove string, remove a.Srv().Go(func() { pluginContext := pluginContext(c) - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.UserHasLeftChannel(pluginContext, cm, actorUser) return true }, plugin.UserHasLeftChannelID) diff --git a/server/channels/app/channels.go b/server/channels/app/channels.go index fc6dd687f7..b6ed4be31e 100644 --- a/server/channels/app/channels.go +++ b/server/channels/app/channels.go @@ -219,7 +219,7 @@ func (ch *Channels) RemoveConfigListener(id string) { ch.cfgSvc.RemoveConfigListener(id) } -func (ch *Channels) RunMultiHook(hookRunnerFunc func(hooks plugin.Hooks) bool, hookId int) { +func (ch *Channels) RunMultiHook(hookRunnerFunc func(hooks plugin.Hooks, manifest *model.Manifest) bool, hookId int) { if env := ch.GetPluginsEnvironment(); env != nil { env.RunMultiPluginHook(hookRunnerFunc, hookId) } diff --git a/server/channels/app/file.go b/server/channels/app/file.go index 0f9d894d0d..8278e778ce 100644 --- a/server/channels/app/file.go +++ b/server/channels/app/file.go @@ -1039,7 +1039,7 @@ func (a *App) DoUploadFileExpectModification(c request.CTX, now time.Time, rawTe var rejectionError *model.AppError pluginContext := pluginContext(c) - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { var newBytes bytes.Buffer replacementInfo, rejectionReason := hooks.FileWillBeUploaded(pluginContext, info, bytes.NewReader(data), &newBytes) if rejectionReason != "" { diff --git a/server/channels/app/login.go b/server/channels/app/login.go index afeaf2bb49..1961a47c47 100644 --- a/server/channels/app/login.go +++ b/server/channels/app/login.go @@ -159,7 +159,7 @@ func (a *App) GetUserForLogin(c request.CTX, id, loginId string) (*model.User, * func (a *App) DoLogin(c request.CTX, w http.ResponseWriter, r *http.Request, user *model.User, deviceID string, isMobile, isOAuthUser, isSaml bool) (*model.Session, *model.AppError) { var rejectionReason string pluginContext := pluginContext(c) - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { rejectionReason = hooks.UserWillLogIn(pluginContext, user) return rejectionReason == "" }, plugin.UserWillLogInID) @@ -230,7 +230,7 @@ func (a *App) DoLogin(c request.CTX, w http.ResponseWriter, r *http.Request, use } a.Srv().Go(func() { - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.UserHasLoggedIn(pluginContext, user) return true }, plugin.UserHasLoggedInID) diff --git a/server/channels/app/notification_push.go b/server/channels/app/notification_push.go index 1a3b9137f6..256f90e41e 100644 --- a/server/channels/app/notification_push.go +++ b/server/channels/app/notification_push.go @@ -91,7 +91,7 @@ func (a *App) sendPushNotificationSync(c request.CTX, post *model.Post, user *mo func (a *App) sendPushNotificationToAllSessions(rctx request.CTX, msg *model.PushNotification, userID string, skipSessionId string) *model.AppError { rejectionReason := "" - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { var replacementNotification *model.PushNotification replacementNotification, rejectionReason = hooks.NotificationWillBePushed(msg, userID) if rejectionReason != "" { diff --git a/server/channels/app/platform/config.go b/server/channels/app/platform/config.go index de1e481c0a..de8cd1cd6e 100644 --- a/server/channels/app/platform/config.go +++ b/server/channels/app/platform/config.go @@ -73,7 +73,7 @@ func (ps *PlatformService) IsConfigReadOnly() bool { func (ps *PlatformService) SaveConfig(newCfg *model.Config, sendConfigChangeClusterMessage bool) (*model.Config, *model.Config, *model.AppError) { if ps.pluginEnv != nil { var hookErr error - ps.pluginEnv.RunMultiHook(func(hooks plugin.Hooks) bool { + ps.pluginEnv.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { var cfg *model.Config cfg, hookErr = hooks.ConfigurationWillBeSaved(newCfg) if hookErr == nil && cfg != nil { diff --git a/server/channels/app/platform/service.go b/server/channels/app/platform/service.go index 4f33af3739..b61d77417b 100644 --- a/server/channels/app/platform/service.go +++ b/server/channels/app/platform/service.go @@ -106,7 +106,7 @@ type PlatformService struct { } type HookRunner interface { - RunMultiHook(hookRunnerFunc func(hooks plugin.Hooks) bool, hookId int) + RunMultiHook(hookRunnerFunc func(hooks plugin.Hooks, _ *model.Manifest) bool, hookId int) GetPluginsEnvironment() *plugin.Environment } diff --git a/server/channels/app/platform/web_conn.go b/server/channels/app/platform/web_conn.go index d83417a874..1090b7fa72 100644 --- a/server/channels/app/platform/web_conn.go +++ b/server/channels/app/platform/web_conn.go @@ -265,7 +265,7 @@ func (ps *PlatformService) NewWebConn(cfg *WebConnConfig, suite SuiteIFace, runn wc.SetActiveThreadViewThreadChannelID(UnsetPresenceIndicator) ps.Go(func() { - runner.RunMultiHook(func(hooks plugin.Hooks) bool { + runner.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.OnWebSocketConnect(wc.GetConnectionID(), userID) return true }, plugin.OnWebSocketConnectID) @@ -278,7 +278,7 @@ func (wc *WebConn) pluginPostedConsumer(wg *sync.WaitGroup) { defer wg.Done() for msg := range wc.pluginPosted { - wc.HookRunner.RunMultiHook(func(hooks plugin.Hooks) bool { + wc.HookRunner.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.WebSocketMessageHasBeenPosted(msg.connectionID, msg.userID, msg.req) return true }, plugin.WebSocketMessageHasBeenPostedID) @@ -417,7 +417,7 @@ func (wc *WebConn) Pump() { userID := wc.UserId wc.Platform.Go(func() { - wc.HookRunner.RunMultiHook(func(hooks plugin.Hooks) bool { + wc.HookRunner.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.OnWebSocketDisconnect(wc.GetConnectionID(), userID) return true }, plugin.OnWebSocketDisconnectID) diff --git a/server/channels/app/platform/web_conn_test.go b/server/channels/app/platform/web_conn_test.go index 1943aeed76..d9e3ea13c6 100644 --- a/server/channels/app/platform/web_conn_test.go +++ b/server/channels/app/platform/web_conn_test.go @@ -22,7 +22,7 @@ import ( type hookRunner struct { } -func (h *hookRunner) RunMultiHook(hookRunnerFunc func(hooks plugin.Hooks) bool, hookId int) { +func (h *hookRunner) RunMultiHook(hookRunnerFunc func(hooks plugin.Hooks, _ *model.Manifest) bool, hookId int) { } func (h *hookRunner) HooksForPlugin(id string) (plugin.Hooks, error) { diff --git a/server/channels/app/plugin.go b/server/channels/app/plugin.go index 707a6da09c..7972d4e2ce 100644 --- a/server/channels/app/plugin.go +++ b/server/channels/app/plugin.go @@ -244,7 +244,7 @@ func (ch *Channels) initPlugins(c request.CTX, pluginDir, webappPluginDir string ch.syncPluginsActiveState() } - ch.RunMultiHook(func(hooks plugin.Hooks) bool { + ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { if err := hooks.OnConfigurationChange(); err != nil { ch.srv.Log().Error("Plugin OnConfigurationChange hook failed", mlog.Err(err)) } diff --git a/server/channels/app/plugin_hooks_test.go b/server/channels/app/plugin_hooks_test.go index 3bdcd97498..49ae594203 100644 --- a/server/channels/app/plugin_hooks_test.go +++ b/server/channels/app/plugin_hooks_test.go @@ -1335,7 +1335,7 @@ func TestHookRunDataRetention(t *testing.T) { require.True(t, th.App.GetPluginsEnvironment().IsActive(pluginID)) hookCalled := false - th.App.Channels().RunMultiHook(func(hooks plugin.Hooks) bool { + th.App.Channels().RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { n, _ := hooks.RunDataRetention(0, 0) // Ensure return it correct assert.Equal(t, int64(100), n) @@ -1379,7 +1379,7 @@ func TestHookOnSendDailyTelemetry(t *testing.T) { require.True(t, th.App.GetPluginsEnvironment().IsActive(pluginID)) hookCalled := false - th.App.Channels().RunMultiHook(func(hooks plugin.Hooks) bool { + th.App.Channels().RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.OnSendDailyTelemetry() hookCalled = true @@ -1423,7 +1423,7 @@ func TestHookOnCloudLimitsUpdated(t *testing.T) { require.True(t, th.App.GetPluginsEnvironment().IsActive(pluginID)) hookCalled := false - th.App.Channels().RunMultiHook(func(hooks plugin.Hooks) bool { + th.App.Channels().RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.OnCloudLimitsUpdated(nil) hookCalled = true diff --git a/server/channels/app/post.go b/server/channels/app/post.go index 86bbfdd600..5b7d5b1124 100644 --- a/server/channels/app/post.go +++ b/server/channels/app/post.go @@ -308,7 +308,7 @@ func (a *App) CreatePost(c request.CTX, post *model.Post, channel *model.Channel } var rejectionError *model.AppError pluginContext := pluginContext(c) - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { replacementPost, rejectionReason := hooks.MessageWillBePosted(pluginContext, post.ForPlugin()) if rejectionReason != "" { id := "Post rejected by plugin. " + rejectionReason @@ -381,7 +381,7 @@ func (a *App) CreatePost(c request.CTX, post *model.Post, channel *model.Channel // and to remove the non-GOB-encodable Metadata from it. pluginPost := rpost.ForPlugin() a.Srv().Go(func() { - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.MessageHasBeenPosted(pluginContext, pluginPost) return true }, plugin.MessageHasBeenPostedID) @@ -738,7 +738,7 @@ func (a *App) UpdatePost(c request.CTX, receivedUpdatedPost *model.Post, safeUpd var rejectionReason string pluginContext := pluginContext(c) - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { newPost, rejectionReason = hooks.MessageWillBeUpdated(pluginContext, newPost.ForPlugin(), oldPost.ForPlugin()) return newPost != nil }, plugin.MessageWillBeUpdatedID) @@ -762,7 +762,7 @@ func (a *App) UpdatePost(c request.CTX, receivedUpdatedPost *model.Post, safeUpd pluginOldPost := oldPost.ForPlugin() pluginNewPost := newPost.ForPlugin() a.Srv().Go(func() { - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.MessageHasBeenUpdated(pluginContext, pluginNewPost, pluginOldPost) return true }, plugin.MessageHasBeenUpdatedID) @@ -2368,7 +2368,7 @@ func (a *App) applyPostsWillBeConsumedHook(posts map[string]*model.Post) { for _, post := range posts { postsSlice = append(postsSlice, post.ForPlugin()) } - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { postReplacements := hooks.MessagesWillBeConsumed(postsSlice) for _, postReplacement := range postReplacements { posts[postReplacement.Id] = postReplacement @@ -2383,7 +2383,7 @@ func (a *App) applyPostWillBeConsumedHook(post **model.Post) { } ps := []*model.Post{*post} - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { rp := hooks.MessagesWillBeConsumed(ps) if len(rp) > 0 { (*post) = rp[0] @@ -2705,7 +2705,7 @@ func (a *App) CleanUpAfterPostDeletion(c request.CTX, post *model.Post, deleteBy pluginPost := post.ForPlugin() pluginContext := pluginContext(c) a.Srv().Go(func() { - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.MessageHasBeenDeleted(pluginContext, pluginPost) return true }, plugin.MessageHasBeenDeletedID) diff --git a/server/channels/app/preference.go b/server/channels/app/preference.go index 677f503159..506d7f58f7 100644 --- a/server/channels/app/preference.go +++ b/server/channels/app/preference.go @@ -77,7 +77,7 @@ func (a *App) UpdatePreferences(c request.CTX, userID string, preferences model. pluginContext := pluginContext(c) a.Srv().Go(func() { - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.PreferencesHaveChanged(pluginContext, preferences) return true }, plugin.PreferencesHaveChangedID) diff --git a/server/channels/app/reaction.go b/server/channels/app/reaction.go index 56048158f3..aaf3ef019a 100644 --- a/server/channels/app/reaction.go +++ b/server/channels/app/reaction.go @@ -84,7 +84,7 @@ func (a *App) SaveReactionForPost(c request.CTX, reaction *model.Reaction) (*mod pluginContext := pluginContext(c) a.Srv().Go(func() { - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.ReactionHasBeenAdded(pluginContext, reaction) return true }, plugin.ReactionHasBeenAddedID) @@ -155,7 +155,7 @@ func (a *App) DeleteReactionForPost(c request.CTX, reaction *model.Reaction) *mo pluginContext := pluginContext(c) a.Srv().Go(func() { - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.ReactionHasBeenRemoved(pluginContext, reaction) return true }, plugin.ReactionHasBeenRemovedID) diff --git a/server/channels/app/support_packet.go b/server/channels/app/support_packet.go index 5ddba8d5b2..ff5772f682 100644 --- a/server/channels/app/support_packet.go +++ b/server/channels/app/support_packet.go @@ -6,6 +6,7 @@ package app import ( "encoding/json" "runtime" + "slices" "sync" "github.com/hashicorp/go-multierror" @@ -13,6 +14,7 @@ import ( "gopkg.in/yaml.v2" "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/public/shared/request" ) @@ -82,26 +84,30 @@ func (a *App) GenerateSupportPacket(c request.CTX, options *model.SupportPacketO wg.Wait() - if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil { - pluginContext := pluginContext(c) - for _, id := range options.PluginPackets { - hooks, err := pluginsEnvironment.HooksForPlugin(id) - if err != nil { - c.Logger().Error("Failed to call hooks for plugin", mlog.Err(err), mlog.String("plugin", id)) - warnings = multierror.Append(warnings, err) - continue - } - pluginData, err := hooks.GenerateSupportData(pluginContext) - if err != nil { - c.Logger().Warn("Failed to generate plugin file for Support Packet", mlog.Err(err), mlog.String("plugin", id)) - warnings = multierror.Append(warnings, err) - continue - } - for _, data := range pluginData { - fileDatas = append(fileDatas, *data) + pluginContext := pluginContext(c) + a.ch.RunMultiHook(func(hooks plugin.Hooks, manifest *model.Manifest) bool { + // If the plugin defined the support_packet prop it means there is a UI element to include it in the support packet. + // Check if the plugin is in the list of plugins to include in the Support Packet. + if _, ok := manifest.Props["support_packet"]; ok { + if !slices.Contains(options.PluginPackets, manifest.Id) { + return true } } - } + + // Otherwise, just call the hook as the plugin decided to always include it in the Support Packet. + pluginData, err := hooks.GenerateSupportData(pluginContext) + if err != nil { + c.Logger().Warn("Failed to generate plugin file for Support Packet", mlog.String("plugin", manifest.Id), mlog.Err(err)) + warnings = multierror.Append(warnings, err) + return true + } + + for _, data := range pluginData { + fileDatas = append(fileDatas, *data) + } + + return true + }, plugin.GenerateSupportDataID) // Adding a warning.txt file to the fileDatas if any warning if warnings != nil { diff --git a/server/channels/app/team.go b/server/channels/app/team.go index ac30d4d34a..b8b55d9685 100644 --- a/server/channels/app/team.go +++ b/server/channels/app/team.go @@ -803,7 +803,7 @@ func (a *App) JoinUserToTeam(c request.CTX, team *model.Team, user *model.User, a.Srv().Go(func() { pluginContext := pluginContext(c) - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.UserHasJoinedTeam(pluginContext, teamMember, actor) return true }, plugin.UserHasJoinedTeamID) @@ -1175,7 +1175,7 @@ func (a *App) postProcessTeamMemberLeave(c request.CTX, teamMember *model.TeamMe a.Srv().Go(func() { pluginContext := pluginContext(c) - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.UserHasLeftTeam(pluginContext, teamMember, actor) return true }, plugin.UserHasLeftTeamID) diff --git a/server/channels/app/upload.go b/server/channels/app/upload.go index 0317d60d63..83bc302058 100644 --- a/server/channels/app/upload.go +++ b/server/channels/app/upload.go @@ -62,7 +62,7 @@ func (a *App) runPluginsHook(c request.CTX, info *model.FileInfo, file io.Reader var rejErr *model.AppError var once sync.Once pluginContext := pluginContext(c) - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { once.Do(func() { hookHasRunCh <- struct{}{} }) diff --git a/server/channels/app/user.go b/server/channels/app/user.go index 90490c5091..f2a0865c87 100644 --- a/server/channels/app/user.go +++ b/server/channels/app/user.go @@ -313,7 +313,7 @@ func (a *App) createUserOrGuest(c request.CTX, user *model.User, guest bool) (*m pluginContext := pluginContext(c) a.Srv().Go(func() { - a.ch.RunMultiHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.UserHasBeenCreated(pluginContext, ruser) return true }, plugin.UserHasBeenCreatedID) @@ -1045,10 +1045,10 @@ func (a *App) UpdateActive(c request.CTX, user *model.User, active bool) (*model a.sendUpdatedUserEvent(ruser) - if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil && !active && user.DeleteAt != 0 { + if !active && user.DeleteAt != 0 { a.Srv().Go(func() { pluginContext := pluginContext(c) - pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool { + a.ch.RunMultiHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.UserHasBeenDeactivated(pluginContext, user) return true }, plugin.UserHasBeenDeactivatedID) diff --git a/server/platform/services/telemetry/telemetry.go b/server/platform/services/telemetry/telemetry.go index 66221a415b..146e366b29 100644 --- a/server/platform/services/telemetry/telemetry.go +++ b/server/platform/services/telemetry/telemetry.go @@ -1065,7 +1065,7 @@ func (ts *TelemetryService) trackPlugins() { "plugins_with_broken_manifests": brokenManifestCount, }) - pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool { + pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks, _ *model.Manifest) bool { hooks.OnSendDailyTelemetry() return true }, plugin.OnSendDailyTelemetryID) diff --git a/server/public/plugin/environment.go b/server/public/plugin/environment.go index 21054ad857..289b55ea83 100644 --- a/server/public/plugin/environment.go +++ b/server/public/plugin/environment.go @@ -599,7 +599,7 @@ func (env *Environment) HooksForPlugin(id string) (Hooks, error) { // // If hookRunnerFunc returns false, iteration will not continue. The iteration order among active // plugins is not specified. -func (env *Environment) RunMultiPluginHook(hookRunnerFunc func(hooks Hooks) bool, hookId int) { +func (env *Environment) RunMultiPluginHook(hookRunnerFunc func(hooks Hooks, manifest *model.Manifest) bool, hookId int) { startTime := time.Now() env.registeredPlugins.Range(func(key, value any) bool { @@ -610,7 +610,7 @@ func (env *Environment) RunMultiPluginHook(hookRunnerFunc func(hooks Hooks) bool } hookStartTime := time.Now() - result := hookRunnerFunc(rp.supervisor.Hooks()) + result := hookRunnerFunc(rp.supervisor.Hooks(), rp.BundleInfo.Manifest) if env.metrics != nil { elapsedTime := float64(time.Since(hookStartTime)) / float64(time.Second) diff --git a/server/public/plugin/hooks.go b/server/public/plugin/hooks.go index a8b33fe97a..c44b36d956 100644 --- a/server/public/plugin/hooks.go +++ b/server/public/plugin/hooks.go @@ -387,6 +387,12 @@ type Hooks interface { // GenerateSupportData is invoked when a Support Packet gets generated. // It allows plugins to include their own content in the Support Packet. // + // Plugins may specififes a "support_packet" field in the manifest props with a custom text. + // By doing so, the plugin will be included in the Support Packet UI and the user will be able to select it. + // This hook will only be called, if the user selects the plugin in the Support Packet UI. + // + // If no "support_packet" is specified, this hook will always be called. + // // Minimum server version: 9.8 GenerateSupportData(c *Context) ([]*model.FileData, error) }