2020-02-14 15:47:43 -05:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
|
// See LICENSE.txt for license information.
|
|
|
|
|
|
|
|
|
|
// Code generated by "make pluginapi"
|
|
|
|
|
// DO NOT EDIT
|
|
|
|
|
|
|
|
|
|
package plugin
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"io"
|
|
|
|
|
"net/http"
|
|
|
|
|
timePkg "time"
|
|
|
|
|
|
2025-03-13 12:00:15 -04:00
|
|
|
saml2 "github.com/mattermost/gosaml2"
|
2023-06-11 01:24:35 -04:00
|
|
|
"github.com/mattermost/mattermost/server/public/model"
|
2020-02-14 15:47:43 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type hooksTimerLayer struct {
|
|
|
|
|
pluginID string
|
|
|
|
|
hooksImpl Hooks
|
2023-05-09 12:30:02 -04:00
|
|
|
metrics metricsInterface
|
2020-02-14 15:47:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) recordTime(startTime timePkg.Time, name string, success bool) {
|
|
|
|
|
if hooks.metrics != nil {
|
|
|
|
|
elapsedTime := float64(timePkg.Since(startTime)) / float64(timePkg.Second)
|
|
|
|
|
hooks.metrics.ObservePluginHookDuration(hooks.pluginID, name, success, elapsedTime)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) OnActivate() error {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA := hooks.hooksImpl.OnActivate()
|
2020-06-12 12:12:37 -04:00
|
|
|
hooks.recordTime(startTime, "OnActivate", _returnsA == nil)
|
2020-02-14 15:47:43 -05:00
|
|
|
return _returnsA
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) Implemented() ([]string, error) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA, _returnsB := hooks.hooksImpl.Implemented()
|
2020-06-12 12:12:37 -04:00
|
|
|
hooks.recordTime(startTime, "Implemented", _returnsB == nil)
|
2020-02-14 15:47:43 -05:00
|
|
|
return _returnsA, _returnsB
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) OnDeactivate() error {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA := hooks.hooksImpl.OnDeactivate()
|
2020-06-12 12:12:37 -04:00
|
|
|
hooks.recordTime(startTime, "OnDeactivate", _returnsA == nil)
|
2020-02-14 15:47:43 -05:00
|
|
|
return _returnsA
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) OnConfigurationChange() error {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA := hooks.hooksImpl.OnConfigurationChange()
|
2020-06-12 12:12:37 -04:00
|
|
|
hooks.recordTime(startTime, "OnConfigurationChange", _returnsA == nil)
|
2020-02-14 15:47:43 -05:00
|
|
|
return _returnsA
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) ServeHTTP(c *Context, w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.ServeHTTP(c, w, r)
|
|
|
|
|
hooks.recordTime(startTime, "ServeHTTP", true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) ExecuteCommand(c *Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA, _returnsB := hooks.hooksImpl.ExecuteCommand(c, args)
|
2020-06-12 12:12:37 -04:00
|
|
|
hooks.recordTime(startTime, "ExecuteCommand", _returnsB == nil)
|
2020-02-14 15:47:43 -05:00
|
|
|
return _returnsA, _returnsB
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) UserHasBeenCreated(c *Context, user *model.User) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.UserHasBeenCreated(c, user)
|
|
|
|
|
hooks.recordTime(startTime, "UserHasBeenCreated", true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) UserWillLogIn(c *Context, user *model.User) string {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA := hooks.hooksImpl.UserWillLogIn(c, user)
|
|
|
|
|
hooks.recordTime(startTime, "UserWillLogIn", true)
|
|
|
|
|
return _returnsA
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) UserHasLoggedIn(c *Context, user *model.User) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.UserHasLoggedIn(c, user)
|
|
|
|
|
hooks.recordTime(startTime, "UserHasLoggedIn", true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) MessageWillBePosted(c *Context, post *model.Post) (*model.Post, string) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA, _returnsB := hooks.hooksImpl.MessageWillBePosted(c, post)
|
|
|
|
|
hooks.recordTime(startTime, "MessageWillBePosted", true)
|
|
|
|
|
return _returnsA, _returnsB
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) MessageWillBeUpdated(c *Context, newPost, oldPost *model.Post) (*model.Post, string) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA, _returnsB := hooks.hooksImpl.MessageWillBeUpdated(c, newPost, oldPost)
|
|
|
|
|
hooks.recordTime(startTime, "MessageWillBeUpdated", true)
|
|
|
|
|
return _returnsA, _returnsB
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) MessageHasBeenPosted(c *Context, post *model.Post) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.MessageHasBeenPosted(c, post)
|
|
|
|
|
hooks.recordTime(startTime, "MessageHasBeenPosted", true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) MessageHasBeenUpdated(c *Context, newPost, oldPost *model.Post) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.MessageHasBeenUpdated(c, newPost, oldPost)
|
|
|
|
|
hooks.recordTime(startTime, "MessageHasBeenUpdated", true)
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-23 10:12:46 -04:00
|
|
|
func (hooks *hooksTimerLayer) MessagesWillBeConsumed(posts []*model.Post) []*model.Post {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA := hooks.hooksImpl.MessagesWillBeConsumed(posts)
|
|
|
|
|
hooks.recordTime(startTime, "MessagesWillBeConsumed", true)
|
|
|
|
|
return _returnsA
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-14 12:33:22 -04:00
|
|
|
func (hooks *hooksTimerLayer) MessageHasBeenDeleted(c *Context, post *model.Post) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.MessageHasBeenDeleted(c, post)
|
|
|
|
|
hooks.recordTime(startTime, "MessageHasBeenDeleted", true)
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-14 15:47:43 -05:00
|
|
|
func (hooks *hooksTimerLayer) ChannelHasBeenCreated(c *Context, channel *model.Channel) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.ChannelHasBeenCreated(c, channel)
|
|
|
|
|
hooks.recordTime(startTime, "ChannelHasBeenCreated", true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) UserHasJoinedChannel(c *Context, channelMember *model.ChannelMember, actor *model.User) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.UserHasJoinedChannel(c, channelMember, actor)
|
|
|
|
|
hooks.recordTime(startTime, "UserHasJoinedChannel", true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) UserHasLeftChannel(c *Context, channelMember *model.ChannelMember, actor *model.User) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.UserHasLeftChannel(c, channelMember, actor)
|
|
|
|
|
hooks.recordTime(startTime, "UserHasLeftChannel", true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) UserHasJoinedTeam(c *Context, teamMember *model.TeamMember, actor *model.User) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.UserHasJoinedTeam(c, teamMember, actor)
|
|
|
|
|
hooks.recordTime(startTime, "UserHasJoinedTeam", true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) UserHasLeftTeam(c *Context, teamMember *model.TeamMember, actor *model.User) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.UserHasLeftTeam(c, teamMember, actor)
|
|
|
|
|
hooks.recordTime(startTime, "UserHasLeftTeam", true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) FileWillBeUploaded(c *Context, info *model.FileInfo, file io.Reader, output io.Writer) (*model.FileInfo, string) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA, _returnsB := hooks.hooksImpl.FileWillBeUploaded(c, info, file, output)
|
|
|
|
|
hooks.recordTime(startTime, "FileWillBeUploaded", true)
|
|
|
|
|
return _returnsA, _returnsB
|
|
|
|
|
}
|
2020-10-31 02:06:43 -04:00
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) ReactionHasBeenAdded(c *Context, reaction *model.Reaction) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.ReactionHasBeenAdded(c, reaction)
|
|
|
|
|
hooks.recordTime(startTime, "ReactionHasBeenAdded", true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) ReactionHasBeenRemoved(c *Context, reaction *model.Reaction) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.ReactionHasBeenRemoved(c, reaction)
|
|
|
|
|
hooks.recordTime(startTime, "ReactionHasBeenRemoved", true)
|
|
|
|
|
}
|
2021-04-28 13:59:32 -04:00
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) OnPluginClusterEvent(c *Context, ev model.PluginClusterEvent) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.OnPluginClusterEvent(c, ev)
|
|
|
|
|
hooks.recordTime(startTime, "OnPluginClusterEvent", true)
|
|
|
|
|
}
|
2021-08-24 04:11:31 -04:00
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) OnWebSocketConnect(webConnID, userID string) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.OnWebSocketConnect(webConnID, userID)
|
|
|
|
|
hooks.recordTime(startTime, "OnWebSocketConnect", true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) OnWebSocketDisconnect(webConnID, userID string) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.OnWebSocketDisconnect(webConnID, userID)
|
|
|
|
|
hooks.recordTime(startTime, "OnWebSocketDisconnect", true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) WebSocketMessageHasBeenPosted(webConnID, userID string, req *model.WebSocketRequest) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.WebSocketMessageHasBeenPosted(webConnID, userID, req)
|
|
|
|
|
hooks.recordTime(startTime, "WebSocketMessageHasBeenPosted", true)
|
|
|
|
|
}
|
2022-01-20 19:46:03 -05:00
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) RunDataRetention(nowTime, batchSize int64) (int64, error) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA, _returnsB := hooks.hooksImpl.RunDataRetention(nowTime, batchSize)
|
|
|
|
|
hooks.recordTime(startTime, "RunDataRetention", _returnsB == nil)
|
|
|
|
|
return _returnsA, _returnsB
|
|
|
|
|
}
|
2022-02-09 14:29:00 -05:00
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) OnInstall(c *Context, event model.OnInstallEvent) error {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA := hooks.hooksImpl.OnInstall(c, event)
|
|
|
|
|
hooks.recordTime(startTime, "OnInstall", _returnsA == nil)
|
|
|
|
|
return _returnsA
|
|
|
|
|
}
|
2022-02-10 00:20:00 -05:00
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) OnSendDailyTelemetry() {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.OnSendDailyTelemetry()
|
|
|
|
|
hooks.recordTime(startTime, "OnSendDailyTelemetry", true)
|
|
|
|
|
}
|
2022-05-09 09:05:50 -04:00
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) OnCloudLimitsUpdated(limits *model.ProductLimits) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.OnCloudLimitsUpdated(limits)
|
|
|
|
|
hooks.recordTime(startTime, "OnCloudLimitsUpdated", true)
|
|
|
|
|
}
|
2022-11-03 14:43:30 -04:00
|
|
|
|
2023-06-12 20:23:02 -04:00
|
|
|
func (hooks *hooksTimerLayer) ConfigurationWillBeSaved(newCfg *model.Config) (*model.Config, error) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA, _returnsB := hooks.hooksImpl.ConfigurationWillBeSaved(newCfg)
|
|
|
|
|
hooks.recordTime(startTime, "ConfigurationWillBeSaved", _returnsB == nil)
|
|
|
|
|
return _returnsA, _returnsB
|
|
|
|
|
}
|
2023-08-18 12:01:50 -04:00
|
|
|
|
2025-08-05 09:09:07 -04:00
|
|
|
func (hooks *hooksTimerLayer) EmailNotificationWillBeSent(emailNotification *model.EmailNotification) (*model.EmailNotificationContent, string) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA, _returnsB := hooks.hooksImpl.EmailNotificationWillBeSent(emailNotification)
|
|
|
|
|
hooks.recordTime(startTime, "EmailNotificationWillBeSent", true)
|
|
|
|
|
return _returnsA, _returnsB
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-24 12:33:53 -04:00
|
|
|
func (hooks *hooksTimerLayer) NotificationWillBePushed(pushNotification *model.PushNotification, userID string) (*model.PushNotification, string) {
|
2023-08-18 12:01:50 -04:00
|
|
|
startTime := timePkg.Now()
|
2023-08-24 12:33:53 -04:00
|
|
|
_returnsA, _returnsB := hooks.hooksImpl.NotificationWillBePushed(pushNotification, userID)
|
2023-08-18 12:01:50 -04:00
|
|
|
hooks.recordTime(startTime, "NotificationWillBePushed", true)
|
2023-08-24 12:33:53 -04:00
|
|
|
return _returnsA, _returnsB
|
2023-08-18 12:01:50 -04:00
|
|
|
}
|
2023-08-30 02:55:20 -04:00
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) UserHasBeenDeactivated(c *Context, user *model.User) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.UserHasBeenDeactivated(c, user)
|
|
|
|
|
hooks.recordTime(startTime, "UserHasBeenDeactivated", true)
|
|
|
|
|
}
|
2023-11-17 15:39:06 -05:00
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) ServeMetrics(c *Context, w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.ServeMetrics(c, w, r)
|
|
|
|
|
hooks.recordTime(startTime, "ServeMetrics", true)
|
|
|
|
|
}
|
Shared channels plugin APIs for MS Teams plugin (#25805)
New plugin APIs and hooks for accessing Shared Channels service via plugin.
- RegisterPluginForSharedChannels(opts model.RegisterPluginOpts) (remoteID string, err error)
- UnregisterPluginForSharedChannels(pluginID string) error
- ShareChannel(sc *model.SharedChannel) (*model.SharedChannel, error)
- UpdateSharedChannel(sc *model.SharedChannel) (*model.SharedChannel, error)
- UnshareChannel(channelID string) (unshared bool, err error)
- UpdateSharedChannelCursor(channelID, remoteID string, cusror model.GetPostsSinceForSyncCursor) error
- SyncSharedChannel(channelID string) error
- InviteRemoteToChannel(channelID string, remoteID string, userID string) error
- UninviteRemoteFromChannel(channelID string, remoteID string) error
Hooks
- OnSharedChannelsSyncMsg(msg *model.SyncMsg, rc *model.RemoteCluster) (model.SyncResponse, error)
- OnSharedChannelsPing(rc *model.RemoteCluster) bool
2023-12-22 17:00:27 -05:00
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) OnSharedChannelsSyncMsg(msg *model.SyncMsg, rc *model.RemoteCluster) (model.SyncResponse, error) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA, _returnsB := hooks.hooksImpl.OnSharedChannelsSyncMsg(msg, rc)
|
|
|
|
|
hooks.recordTime(startTime, "OnSharedChannelsSyncMsg", _returnsB == nil)
|
|
|
|
|
return _returnsA, _returnsB
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) OnSharedChannelsPing(rc *model.RemoteCluster) bool {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA := hooks.hooksImpl.OnSharedChannelsPing(rc)
|
|
|
|
|
hooks.recordTime(startTime, "OnSharedChannelsPing", true)
|
|
|
|
|
return _returnsA
|
|
|
|
|
}
|
2024-01-03 12:25:53 -05:00
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) PreferencesHaveChanged(c *Context, preferences []model.Preference) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
hooks.hooksImpl.PreferencesHaveChanged(c, preferences)
|
|
|
|
|
hooks.recordTime(startTime, "PreferencesHaveChanged", true)
|
|
|
|
|
}
|
2024-01-16 09:48:51 -05:00
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) OnSharedChannelsAttachmentSyncMsg(fi *model.FileInfo, post *model.Post, rc *model.RemoteCluster) error {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA := hooks.hooksImpl.OnSharedChannelsAttachmentSyncMsg(fi, post, rc)
|
|
|
|
|
hooks.recordTime(startTime, "OnSharedChannelsAttachmentSyncMsg", _returnsA == nil)
|
|
|
|
|
return _returnsA
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) OnSharedChannelsProfileImageSyncMsg(user *model.User, rc *model.RemoteCluster) error {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA := hooks.hooksImpl.OnSharedChannelsProfileImageSyncMsg(user, rc)
|
|
|
|
|
hooks.recordTime(startTime, "OnSharedChannelsProfileImageSyncMsg", _returnsA == nil)
|
|
|
|
|
return _returnsA
|
|
|
|
|
}
|
2024-04-12 04:05:58 -04:00
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) GenerateSupportData(c *Context) ([]*model.FileData, error) {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA, _returnsB := hooks.hooksImpl.GenerateSupportData(c)
|
|
|
|
|
hooks.recordTime(startTime, "GenerateSupportData", _returnsB == nil)
|
|
|
|
|
return _returnsA, _returnsB
|
|
|
|
|
}
|
2025-03-13 12:00:15 -04:00
|
|
|
|
|
|
|
|
func (hooks *hooksTimerLayer) OnSAMLLogin(c *Context, user *model.User, assertion *saml2.AssertionInfo) error {
|
|
|
|
|
startTime := timePkg.Now()
|
|
|
|
|
_returnsA := hooks.hooksImpl.OnSAMLLogin(c, user, assertion)
|
|
|
|
|
hooks.recordTime(startTime, "OnSAMLLogin", _returnsA == nil)
|
|
|
|
|
return _returnsA
|
|
|
|
|
}
|