""" @generated by mypy-protobuf. Do not edit manually! isort:skip_file Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. See LICENSE.txt for license information. """ from collections import abc as _abc from grpc import aio as _aio import abc as _abc_1 import grpc as _grpc import hooks_command_pb2 as _hooks_command_pb2 import hooks_http_pb2 as _hooks_http_pb2 import hooks_lifecycle_pb2 as _hooks_lifecycle_pb2 import hooks_message_pb2 as _hooks_message_pb2 import hooks_user_channel_pb2 as _hooks_user_channel_pb2 import sys import typing as _typing if sys.version_info >= (3, 11): from typing import Self as _Self else: from typing_extensions import Self as _Self _T = _typing.TypeVar("_T") class _MaybeAsyncIterator(_abc.AsyncIterator[_T], _abc.Iterator[_T], metaclass=_abc_1.ABCMeta): ... class _ServicerContext(_grpc.ServicerContext, _aio.ServicerContext): # type: ignore[misc, type-arg] ... GRPC_GENERATED_VERSION: str GRPC_VERSION: str class PluginHooksStub: """============================================================================== PLUGIN HOOKS SERVICE ============================================================================== This service defines the gRPC interface for invoking plugin hooks. The Go server implements this service's client to call into Python plugins. Python plugins implement this service's server to receive hook invocations. Direction: Server -> Plugin (server calls plugin hooks) ERROR HANDLING CONVENTION: -------------------------- For hooks whose Go signature returns `error`: - Errors are encoded in the response message's `error` field (AppError) - gRPC status codes are reserved for transport-level failures only For hooks whose Go signature returns nothing (void): - Response message has no `error` field - Hook failures are logged server-side but do not propagate HOOK GROUPS: ------------ This file imports and exposes RPCs for different hook categories: - hooks_lifecycle.proto: Lifecycle and system hooks (this plan: 03-01) - hooks_message.proto: Message hooks (planned: 03-02) - hooks_user_channel.proto: User and channel hooks (03-03) - hooks_command.proto: Command, WebSocket, cluster, shared channels hooks (03-04) ============================================================================== PluginHooks is the gRPC service for invoking plugin hooks. The server acts as the gRPC client, calling into the plugin process. The plugin acts as the gRPC server, implementing the hook handlers. =========================================================================== LIFECYCLE HOOKS =========================================================================== """ @_typing.overload def __new__(cls, channel: _grpc.Channel) -> _Self: ... @_typing.overload def __new__(cls, channel: _aio.Channel) -> PluginHooksAsyncStub: ... Implemented: _grpc.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.ImplementedRequest, _hooks_lifecycle_pb2.ImplementedResponse] """Implemented returns the list of hooks that the plugin implements. Called during plugin startup to optimize hook dispatch. Plugins that don't implement this are assumed to implement all hooks. Go signature: Implemented() ([]string, error) """ OnActivate: _grpc.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.OnActivateRequest, _hooks_lifecycle_pb2.OnActivateResponse] """OnActivate is invoked when the plugin is activated. If an error is returned, the plugin will be terminated. The plugin will not receive hooks until after OnActivate returns without error. OnConfigurationChange will be called once before OnActivate. Go signature: OnActivate() error """ OnDeactivate: _grpc.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.OnDeactivateRequest, _hooks_lifecycle_pb2.OnDeactivateResponse] """OnDeactivate is invoked when the plugin is deactivated. This is the plugin's last chance to use the API. The plugin will be terminated shortly after this invocation. Go signature: OnDeactivate() error """ OnConfigurationChange: _grpc.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.OnConfigurationChangeRequest, _hooks_lifecycle_pb2.OnConfigurationChangeResponse] """OnConfigurationChange is invoked when configuration changes may have been made. Any returned error is logged but does not stop the plugin. It is called once before OnActivate. Go signature: OnConfigurationChange() error """ OnInstall: _grpc.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.OnInstallRequest, _hooks_lifecycle_pb2.OnInstallResponse] """=========================================================================== SYSTEM HOOKS =========================================================================== OnInstall is invoked after the installation of a plugin as part of onboarding. It's called on every installation, not only once. Go signature: OnInstall(c *Context, event model.OnInstallEvent) error """ OnSendDailyTelemetry: _grpc.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.OnSendDailyTelemetryRequest, _hooks_lifecycle_pb2.OnSendDailyTelemetryResponse] """OnSendDailyTelemetry is invoked when the server sends daily telemetry data. Plugins can use this to send their own telemetry metrics. Go signature: OnSendDailyTelemetry() """ RunDataRetention: _grpc.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.RunDataRetentionRequest, _hooks_lifecycle_pb2.RunDataRetentionResponse] """RunDataRetention is invoked during a DataRetentionJob. Plugins should delete data older than their retention policy. Go signature: RunDataRetention(nowTime, batchSize int64) (int64, error) """ OnCloudLimitsUpdated: _grpc.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.OnCloudLimitsUpdatedRequest, _hooks_lifecycle_pb2.OnCloudLimitsUpdatedResponse] """OnCloudLimitsUpdated is invoked when cloud product limits change. For example, when plan tiers change affecting storage or message limits. Go signature: OnCloudLimitsUpdated(limits *model.ProductLimits) """ ConfigurationWillBeSaved: _grpc.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.ConfigurationWillBeSavedRequest, _hooks_lifecycle_pb2.ConfigurationWillBeSavedResponse] """ConfigurationWillBeSaved is invoked before saving configuration to the backing store. An error can be returned to reject the operation. Additionally, a new config object can be returned to be stored in place of the provided one. Go signature: ConfigurationWillBeSaved(newCfg *model.Config) (*model.Config, error) """ MessageWillBePosted: _grpc.UnaryUnaryMultiCallable[_hooks_message_pb2.MessageWillBePostedRequest, _hooks_message_pb2.MessageWillBePostedResponse] """=========================================================================== MESSAGE HOOKS =========================================================================== MessageWillBePosted is invoked when a message is posted before it is committed to the database. Use this to modify or reject posts before they are saved. Return values: - To allow unchanged: return nil post and empty string - To modify: return modified post and empty string - To reject: return nil post and rejection reason string - To dismiss silently: return nil post and "plugin.message_will_be_posted.dismiss_post" Go signature: MessageWillBePosted(c *Context, post *model.Post) (*model.Post, string) """ MessageWillBeUpdated: _grpc.UnaryUnaryMultiCallable[_hooks_message_pb2.MessageWillBeUpdatedRequest, _hooks_message_pb2.MessageWillBeUpdatedResponse] """MessageWillBeUpdated is invoked when a message is updated before it is committed to the database. Use this to modify or reject post updates. Return values: - To allow unchanged: return nil post and empty string - To modify: return modified post and empty string - To reject: return nil post and rejection reason (post stays unchanged) Go signature: MessageWillBeUpdated(c *Context, newPost, oldPost *model.Post) (*model.Post, string) """ MessageHasBeenPosted: _grpc.UnaryUnaryMultiCallable[_hooks_message_pb2.MessageHasBeenPostedRequest, _hooks_message_pb2.MessageHasBeenPostedResponse] """MessageHasBeenPosted is invoked after the message has been committed to the database. This is a notification hook - you cannot modify or reject the post. Use MessageWillBePosted if you need to modify or reject. Go signature: MessageHasBeenPosted(c *Context, post *model.Post) """ MessageHasBeenUpdated: _grpc.UnaryUnaryMultiCallable[_hooks_message_pb2.MessageHasBeenUpdatedRequest, _hooks_message_pb2.MessageHasBeenUpdatedResponse] """MessageHasBeenUpdated is invoked after a message update has been committed to the database. This is a notification hook - you cannot modify or reject the update. Use MessageWillBeUpdated if you need to modify or reject. Go signature: MessageHasBeenUpdated(c *Context, newPost, oldPost *model.Post) """ MessagesWillBeConsumed: _grpc.UnaryUnaryMultiCallable[_hooks_message_pb2.MessagesWillBeConsumedRequest, _hooks_message_pb2.MessagesWillBeConsumedResponse] """MessagesWillBeConsumed is invoked when messages are requested by a client before they are returned. Use this to filter or modify posts before delivery. Note: This hook has no Context parameter and no error return. Go signature: MessagesWillBeConsumed(posts []*model.Post) []*model.Post """ MessageHasBeenDeleted: _grpc.UnaryUnaryMultiCallable[_hooks_message_pb2.MessageHasBeenDeletedRequest, _hooks_message_pb2.MessageHasBeenDeletedResponse] """MessageHasBeenDeleted is invoked after a message has been deleted from the database. This is a notification hook - you cannot undo the deletion. Go signature: MessageHasBeenDeleted(c *Context, post *model.Post) """ FileWillBeUploaded: _grpc.UnaryUnaryMultiCallable[_hooks_message_pb2.FileWillBeUploadedRequest, _hooks_message_pb2.FileWillBeUploadedResponse] """FileWillBeUploaded is invoked when a file is uploaded before it is committed to storage. Use this to modify or reject file uploads. Note: Phase 8 will add streaming support. Currently uses bytes for file content. Return values: - To allow unchanged: return nil FileInfo, empty bytes, empty string - To modify: return modified FileInfo and/or content, empty string - To reject: return nil FileInfo, empty bytes, and rejection reason Go signature: FileWillBeUploaded(c *Context, info *model.FileInfo, file io.Reader, output io.Writer) (*model.FileInfo, string) """ ReactionHasBeenAdded: _grpc.UnaryUnaryMultiCallable[_hooks_message_pb2.ReactionHasBeenAddedRequest, _hooks_message_pb2.ReactionHasBeenAddedResponse] """ReactionHasBeenAdded is invoked after a reaction has been committed to the database. This is a notification hook. Go signature: ReactionHasBeenAdded(c *Context, reaction *model.Reaction) """ ReactionHasBeenRemoved: _grpc.UnaryUnaryMultiCallable[_hooks_message_pb2.ReactionHasBeenRemovedRequest, _hooks_message_pb2.ReactionHasBeenRemovedResponse] """ReactionHasBeenRemoved is invoked after a reaction has been removed from the database. This is a notification hook. Go signature: ReactionHasBeenRemoved(c *Context, reaction *model.Reaction) """ NotificationWillBePushed: _grpc.UnaryUnaryMultiCallable[_hooks_message_pb2.NotificationWillBePushedRequest, _hooks_message_pb2.NotificationWillBePushedResponse] """NotificationWillBePushed is invoked before a push notification is sent to the push notification server. Use this to modify or reject push notifications. Note: This hook has no Context parameter. Return values: - To allow unchanged: return nil notification and empty string - To modify: return modified notification and empty string - To reject: return nil notification and rejection reason Go signature: NotificationWillBePushed(pushNotification *model.PushNotification, userID string) (*model.PushNotification, string) """ EmailNotificationWillBeSent: _grpc.UnaryUnaryMultiCallable[_hooks_message_pb2.EmailNotificationWillBeSentRequest, _hooks_message_pb2.EmailNotificationWillBeSentResponse] """EmailNotificationWillBeSent is invoked before an email notification is sent. Use this to customize email content or reject the notification. Note: Core identifiers (PostId, ChannelId, etc.) are immutable. Only content fields (subject, title, message, etc.) can be modified. Note: This hook has no Context parameter. Return values: - To allow unchanged: return nil content and empty string - To modify: return modified EmailNotificationContent and empty string - To reject: return nil content and rejection reason Go signature: EmailNotificationWillBeSent(emailNotification *model.EmailNotification) (*model.EmailNotificationContent, string) """ PreferencesHaveChanged: _grpc.UnaryUnaryMultiCallable[_hooks_message_pb2.PreferencesHaveChangedRequest, _hooks_message_pb2.PreferencesHaveChangedResponse] """PreferencesHaveChanged is invoked after one or more of a user's preferences have changed. This is a notification hook. Go signature: PreferencesHaveChanged(c *Context, preferences []model.Preference) """ UserHasBeenCreated: _grpc.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserHasBeenCreatedRequest, _hooks_user_channel_pb2.UserHasBeenCreatedResponse] """=========================================================================== USER HOOKS =========================================================================== UserHasBeenCreated is invoked after a user was created. This is a notification hook - you cannot modify or reject the creation. Go signature: UserHasBeenCreated(c *Context, user *model.User) """ UserWillLogIn: _grpc.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserWillLogInRequest, _hooks_user_channel_pb2.UserWillLogInResponse] """UserWillLogIn is invoked before the login of the user is returned. Return a non-empty string to reject the login. If you don't need to reject the login event, see UserHasLoggedIn. Go signature: UserWillLogIn(c *Context, user *model.User) string """ UserHasLoggedIn: _grpc.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserHasLoggedInRequest, _hooks_user_channel_pb2.UserHasLoggedInResponse] """UserHasLoggedIn is invoked after a user has logged in. This is a notification hook - you cannot modify or reject the login. Go signature: UserHasLoggedIn(c *Context, user *model.User) """ UserHasBeenDeactivated: _grpc.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserHasBeenDeactivatedRequest, _hooks_user_channel_pb2.UserHasBeenDeactivatedResponse] """UserHasBeenDeactivated is invoked when a user is deactivated. This is a notification hook. Go signature: UserHasBeenDeactivated(c *Context, user *model.User) """ OnSAMLLogin: _grpc.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.OnSAMLLoginRequest, _hooks_user_channel_pb2.OnSAMLLoginResponse] """OnSAMLLogin is invoked after a successful SAML login. Return an error to reject the login. Go signature: OnSAMLLogin(c *Context, user *model.User, assertion *saml2.AssertionInfo) error """ ChannelHasBeenCreated: _grpc.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.ChannelHasBeenCreatedRequest, _hooks_user_channel_pb2.ChannelHasBeenCreatedResponse] """=========================================================================== CHANNEL AND TEAM HOOKS =========================================================================== ChannelHasBeenCreated is invoked after a channel has been created. This is a notification hook - you cannot modify or reject the creation. Go signature: ChannelHasBeenCreated(c *Context, channel *model.Channel) """ UserHasJoinedChannel: _grpc.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserHasJoinedChannelRequest, _hooks_user_channel_pb2.UserHasJoinedChannelResponse] """UserHasJoinedChannel is invoked after a user has joined a channel. This is a notification hook. The actor is optional (nil if self-join). Go signature: UserHasJoinedChannel(c *Context, channelMember *model.ChannelMember, actor *model.User) """ UserHasLeftChannel: _grpc.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserHasLeftChannelRequest, _hooks_user_channel_pb2.UserHasLeftChannelResponse] """UserHasLeftChannel is invoked after a user has left a channel. This is a notification hook. The actor is optional (nil if self-removal). Go signature: UserHasLeftChannel(c *Context, channelMember *model.ChannelMember, actor *model.User) """ UserHasJoinedTeam: _grpc.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserHasJoinedTeamRequest, _hooks_user_channel_pb2.UserHasJoinedTeamResponse] """UserHasJoinedTeam is invoked after a user has joined a team. This is a notification hook. The actor is optional (nil if self-join). Go signature: UserHasJoinedTeam(c *Context, teamMember *model.TeamMember, actor *model.User) """ UserHasLeftTeam: _grpc.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserHasLeftTeamRequest, _hooks_user_channel_pb2.UserHasLeftTeamResponse] """UserHasLeftTeam is invoked after a user has left a team. This is a notification hook. The actor is optional (nil if self-removal). Go signature: UserHasLeftTeam(c *Context, teamMember *model.TeamMember, actor *model.User) """ ExecuteCommand: _grpc.UnaryUnaryMultiCallable[_hooks_command_pb2.ExecuteCommandRequest, _hooks_command_pb2.ExecuteCommandResponse] """=========================================================================== COMMAND HOOKS =========================================================================== ExecuteCommand executes a registered slash command. Go signature: ExecuteCommand(c *Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) """ OnWebSocketConnect: _grpc.UnaryUnaryMultiCallable[_hooks_command_pb2.OnWebSocketConnectRequest, _hooks_command_pb2.OnWebSocketConnectResponse] """=========================================================================== WEBSOCKET HOOKS =========================================================================== OnWebSocketConnect is invoked when a new WebSocket connection is opened. This is a notification hook with no Context parameter. Go signature: OnWebSocketConnect(webConnID, userID string) """ OnWebSocketDisconnect: _grpc.UnaryUnaryMultiCallable[_hooks_command_pb2.OnWebSocketDisconnectRequest, _hooks_command_pb2.OnWebSocketDisconnectResponse] """OnWebSocketDisconnect is invoked when a WebSocket connection is closed. This is a notification hook with no Context parameter. Go signature: OnWebSocketDisconnect(webConnID, userID string) """ WebSocketMessageHasBeenPosted: _grpc.UnaryUnaryMultiCallable[_hooks_command_pb2.WebSocketMessageHasBeenPostedRequest, _hooks_command_pb2.WebSocketMessageHasBeenPostedResponse] """WebSocketMessageHasBeenPosted is invoked when a WebSocket message is received. This is a notification hook with no Context parameter. Go signature: WebSocketMessageHasBeenPosted(webConnID, userID string, req *model.WebSocketRequest) """ OnPluginClusterEvent: _grpc.UnaryUnaryMultiCallable[_hooks_command_pb2.OnPluginClusterEventRequest, _hooks_command_pb2.OnPluginClusterEventResponse] """=========================================================================== CLUSTER HOOKS =========================================================================== OnPluginClusterEvent is invoked when an intra-cluster plugin event is received. Used for communication between plugin instances in a High-Availability cluster. This is a notification hook. Go signature: OnPluginClusterEvent(c *Context, ev model.PluginClusterEvent) """ OnSharedChannelsSyncMsg: _grpc.UnaryUnaryMultiCallable[_hooks_command_pb2.OnSharedChannelsSyncMsgRequest, _hooks_command_pb2.OnSharedChannelsSyncMsgResponse] """=========================================================================== SHARED CHANNELS HOOKS =========================================================================== OnSharedChannelsSyncMsg is invoked when a shared channels sync message is received. Plugins can use this to synchronize data with remote clusters. Go signature: OnSharedChannelsSyncMsg(msg *model.SyncMsg, rc *model.RemoteCluster) (model.SyncResponse, error) """ OnSharedChannelsPing: _grpc.UnaryUnaryMultiCallable[_hooks_command_pb2.OnSharedChannelsPingRequest, _hooks_command_pb2.OnSharedChannelsPingResponse] """OnSharedChannelsPing is invoked to check the health of the shared channels plugin. Return true if the plugin and upstream connections are healthy. Go signature: OnSharedChannelsPing(rc *model.RemoteCluster) bool """ OnSharedChannelsAttachmentSyncMsg: _grpc.UnaryUnaryMultiCallable[_hooks_command_pb2.OnSharedChannelsAttachmentSyncMsgRequest, _hooks_command_pb2.OnSharedChannelsAttachmentSyncMsgResponse] """OnSharedChannelsAttachmentSyncMsg is invoked when a file attachment sync message is received. Used to synchronize file attachments between shared channel participants. Go signature: OnSharedChannelsAttachmentSyncMsg(fi *model.FileInfo, post *model.Post, rc *model.RemoteCluster) error """ OnSharedChannelsProfileImageSyncMsg: _grpc.UnaryUnaryMultiCallable[_hooks_command_pb2.OnSharedChannelsProfileImageSyncMsgRequest, _hooks_command_pb2.OnSharedChannelsProfileImageSyncMsgResponse] """OnSharedChannelsProfileImageSyncMsg is invoked when a profile image sync message is received. Used to synchronize user profile images between shared channel participants. Go signature: OnSharedChannelsProfileImageSyncMsg(user *model.User, rc *model.RemoteCluster) error """ GenerateSupportData: _grpc.UnaryUnaryMultiCallable[_hooks_command_pb2.GenerateSupportDataRequest, _hooks_command_pb2.GenerateSupportDataResponse] """=========================================================================== SUPPORT HOOKS =========================================================================== GenerateSupportData is invoked when a Support Packet is generated. Plugins can include their own diagnostic data in the support packet. Go signature: GenerateSupportData(c *Context) ([]*model.FileData, error) """ ServeHTTP: _grpc.StreamStreamMultiCallable[_hooks_http_pb2.ServeHTTPRequest, _hooks_http_pb2.ServeHTTPResponse] """=========================================================================== HTTP STREAMING HOOKS (Phase 8) =========================================================================== ServeHTTP handles HTTP requests to /plugins/{plugin_id}. Uses bidirectional streaming for efficient large body transfer. Request flow (Go -> Python): - First message: init metadata (method, URL, headers) + optional first body chunk - Subsequent messages: body chunks until body_complete=true Response flow (Python -> Go): - First message: init metadata (status, headers) + optional first body chunk - Subsequent messages: body chunks until body_complete=true Cancellation: HTTP client disconnect propagates via gRPC context. Body chunks are 64KB by default (configurable). Go signature: ServeHTTP(c *Context, w http.ResponseWriter, r *http.Request) """ @_typing.type_check_only class PluginHooksAsyncStub(PluginHooksStub): """============================================================================== PLUGIN HOOKS SERVICE ============================================================================== This service defines the gRPC interface for invoking plugin hooks. The Go server implements this service's client to call into Python plugins. Python plugins implement this service's server to receive hook invocations. Direction: Server -> Plugin (server calls plugin hooks) ERROR HANDLING CONVENTION: -------------------------- For hooks whose Go signature returns `error`: - Errors are encoded in the response message's `error` field (AppError) - gRPC status codes are reserved for transport-level failures only For hooks whose Go signature returns nothing (void): - Response message has no `error` field - Hook failures are logged server-side but do not propagate HOOK GROUPS: ------------ This file imports and exposes RPCs for different hook categories: - hooks_lifecycle.proto: Lifecycle and system hooks (this plan: 03-01) - hooks_message.proto: Message hooks (planned: 03-02) - hooks_user_channel.proto: User and channel hooks (03-03) - hooks_command.proto: Command, WebSocket, cluster, shared channels hooks (03-04) ============================================================================== PluginHooks is the gRPC service for invoking plugin hooks. The server acts as the gRPC client, calling into the plugin process. The plugin acts as the gRPC server, implementing the hook handlers. =========================================================================== LIFECYCLE HOOKS =========================================================================== """ def __init__(self, channel: _aio.Channel) -> None: ... Implemented: _aio.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.ImplementedRequest, _hooks_lifecycle_pb2.ImplementedResponse] # type: ignore[assignment] """Implemented returns the list of hooks that the plugin implements. Called during plugin startup to optimize hook dispatch. Plugins that don't implement this are assumed to implement all hooks. Go signature: Implemented() ([]string, error) """ OnActivate: _aio.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.OnActivateRequest, _hooks_lifecycle_pb2.OnActivateResponse] # type: ignore[assignment] """OnActivate is invoked when the plugin is activated. If an error is returned, the plugin will be terminated. The plugin will not receive hooks until after OnActivate returns without error. OnConfigurationChange will be called once before OnActivate. Go signature: OnActivate() error """ OnDeactivate: _aio.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.OnDeactivateRequest, _hooks_lifecycle_pb2.OnDeactivateResponse] # type: ignore[assignment] """OnDeactivate is invoked when the plugin is deactivated. This is the plugin's last chance to use the API. The plugin will be terminated shortly after this invocation. Go signature: OnDeactivate() error """ OnConfigurationChange: _aio.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.OnConfigurationChangeRequest, _hooks_lifecycle_pb2.OnConfigurationChangeResponse] # type: ignore[assignment] """OnConfigurationChange is invoked when configuration changes may have been made. Any returned error is logged but does not stop the plugin. It is called once before OnActivate. Go signature: OnConfigurationChange() error """ OnInstall: _aio.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.OnInstallRequest, _hooks_lifecycle_pb2.OnInstallResponse] # type: ignore[assignment] """=========================================================================== SYSTEM HOOKS =========================================================================== OnInstall is invoked after the installation of a plugin as part of onboarding. It's called on every installation, not only once. Go signature: OnInstall(c *Context, event model.OnInstallEvent) error """ OnSendDailyTelemetry: _aio.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.OnSendDailyTelemetryRequest, _hooks_lifecycle_pb2.OnSendDailyTelemetryResponse] # type: ignore[assignment] """OnSendDailyTelemetry is invoked when the server sends daily telemetry data. Plugins can use this to send their own telemetry metrics. Go signature: OnSendDailyTelemetry() """ RunDataRetention: _aio.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.RunDataRetentionRequest, _hooks_lifecycle_pb2.RunDataRetentionResponse] # type: ignore[assignment] """RunDataRetention is invoked during a DataRetentionJob. Plugins should delete data older than their retention policy. Go signature: RunDataRetention(nowTime, batchSize int64) (int64, error) """ OnCloudLimitsUpdated: _aio.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.OnCloudLimitsUpdatedRequest, _hooks_lifecycle_pb2.OnCloudLimitsUpdatedResponse] # type: ignore[assignment] """OnCloudLimitsUpdated is invoked when cloud product limits change. For example, when plan tiers change affecting storage or message limits. Go signature: OnCloudLimitsUpdated(limits *model.ProductLimits) """ ConfigurationWillBeSaved: _aio.UnaryUnaryMultiCallable[_hooks_lifecycle_pb2.ConfigurationWillBeSavedRequest, _hooks_lifecycle_pb2.ConfigurationWillBeSavedResponse] # type: ignore[assignment] """ConfigurationWillBeSaved is invoked before saving configuration to the backing store. An error can be returned to reject the operation. Additionally, a new config object can be returned to be stored in place of the provided one. Go signature: ConfigurationWillBeSaved(newCfg *model.Config) (*model.Config, error) """ MessageWillBePosted: _aio.UnaryUnaryMultiCallable[_hooks_message_pb2.MessageWillBePostedRequest, _hooks_message_pb2.MessageWillBePostedResponse] # type: ignore[assignment] """=========================================================================== MESSAGE HOOKS =========================================================================== MessageWillBePosted is invoked when a message is posted before it is committed to the database. Use this to modify or reject posts before they are saved. Return values: - To allow unchanged: return nil post and empty string - To modify: return modified post and empty string - To reject: return nil post and rejection reason string - To dismiss silently: return nil post and "plugin.message_will_be_posted.dismiss_post" Go signature: MessageWillBePosted(c *Context, post *model.Post) (*model.Post, string) """ MessageWillBeUpdated: _aio.UnaryUnaryMultiCallable[_hooks_message_pb2.MessageWillBeUpdatedRequest, _hooks_message_pb2.MessageWillBeUpdatedResponse] # type: ignore[assignment] """MessageWillBeUpdated is invoked when a message is updated before it is committed to the database. Use this to modify or reject post updates. Return values: - To allow unchanged: return nil post and empty string - To modify: return modified post and empty string - To reject: return nil post and rejection reason (post stays unchanged) Go signature: MessageWillBeUpdated(c *Context, newPost, oldPost *model.Post) (*model.Post, string) """ MessageHasBeenPosted: _aio.UnaryUnaryMultiCallable[_hooks_message_pb2.MessageHasBeenPostedRequest, _hooks_message_pb2.MessageHasBeenPostedResponse] # type: ignore[assignment] """MessageHasBeenPosted is invoked after the message has been committed to the database. This is a notification hook - you cannot modify or reject the post. Use MessageWillBePosted if you need to modify or reject. Go signature: MessageHasBeenPosted(c *Context, post *model.Post) """ MessageHasBeenUpdated: _aio.UnaryUnaryMultiCallable[_hooks_message_pb2.MessageHasBeenUpdatedRequest, _hooks_message_pb2.MessageHasBeenUpdatedResponse] # type: ignore[assignment] """MessageHasBeenUpdated is invoked after a message update has been committed to the database. This is a notification hook - you cannot modify or reject the update. Use MessageWillBeUpdated if you need to modify or reject. Go signature: MessageHasBeenUpdated(c *Context, newPost, oldPost *model.Post) """ MessagesWillBeConsumed: _aio.UnaryUnaryMultiCallable[_hooks_message_pb2.MessagesWillBeConsumedRequest, _hooks_message_pb2.MessagesWillBeConsumedResponse] # type: ignore[assignment] """MessagesWillBeConsumed is invoked when messages are requested by a client before they are returned. Use this to filter or modify posts before delivery. Note: This hook has no Context parameter and no error return. Go signature: MessagesWillBeConsumed(posts []*model.Post) []*model.Post """ MessageHasBeenDeleted: _aio.UnaryUnaryMultiCallable[_hooks_message_pb2.MessageHasBeenDeletedRequest, _hooks_message_pb2.MessageHasBeenDeletedResponse] # type: ignore[assignment] """MessageHasBeenDeleted is invoked after a message has been deleted from the database. This is a notification hook - you cannot undo the deletion. Go signature: MessageHasBeenDeleted(c *Context, post *model.Post) """ FileWillBeUploaded: _aio.UnaryUnaryMultiCallable[_hooks_message_pb2.FileWillBeUploadedRequest, _hooks_message_pb2.FileWillBeUploadedResponse] # type: ignore[assignment] """FileWillBeUploaded is invoked when a file is uploaded before it is committed to storage. Use this to modify or reject file uploads. Note: Phase 8 will add streaming support. Currently uses bytes for file content. Return values: - To allow unchanged: return nil FileInfo, empty bytes, empty string - To modify: return modified FileInfo and/or content, empty string - To reject: return nil FileInfo, empty bytes, and rejection reason Go signature: FileWillBeUploaded(c *Context, info *model.FileInfo, file io.Reader, output io.Writer) (*model.FileInfo, string) """ ReactionHasBeenAdded: _aio.UnaryUnaryMultiCallable[_hooks_message_pb2.ReactionHasBeenAddedRequest, _hooks_message_pb2.ReactionHasBeenAddedResponse] # type: ignore[assignment] """ReactionHasBeenAdded is invoked after a reaction has been committed to the database. This is a notification hook. Go signature: ReactionHasBeenAdded(c *Context, reaction *model.Reaction) """ ReactionHasBeenRemoved: _aio.UnaryUnaryMultiCallable[_hooks_message_pb2.ReactionHasBeenRemovedRequest, _hooks_message_pb2.ReactionHasBeenRemovedResponse] # type: ignore[assignment] """ReactionHasBeenRemoved is invoked after a reaction has been removed from the database. This is a notification hook. Go signature: ReactionHasBeenRemoved(c *Context, reaction *model.Reaction) """ NotificationWillBePushed: _aio.UnaryUnaryMultiCallable[_hooks_message_pb2.NotificationWillBePushedRequest, _hooks_message_pb2.NotificationWillBePushedResponse] # type: ignore[assignment] """NotificationWillBePushed is invoked before a push notification is sent to the push notification server. Use this to modify or reject push notifications. Note: This hook has no Context parameter. Return values: - To allow unchanged: return nil notification and empty string - To modify: return modified notification and empty string - To reject: return nil notification and rejection reason Go signature: NotificationWillBePushed(pushNotification *model.PushNotification, userID string) (*model.PushNotification, string) """ EmailNotificationWillBeSent: _aio.UnaryUnaryMultiCallable[_hooks_message_pb2.EmailNotificationWillBeSentRequest, _hooks_message_pb2.EmailNotificationWillBeSentResponse] # type: ignore[assignment] """EmailNotificationWillBeSent is invoked before an email notification is sent. Use this to customize email content or reject the notification. Note: Core identifiers (PostId, ChannelId, etc.) are immutable. Only content fields (subject, title, message, etc.) can be modified. Note: This hook has no Context parameter. Return values: - To allow unchanged: return nil content and empty string - To modify: return modified EmailNotificationContent and empty string - To reject: return nil content and rejection reason Go signature: EmailNotificationWillBeSent(emailNotification *model.EmailNotification) (*model.EmailNotificationContent, string) """ PreferencesHaveChanged: _aio.UnaryUnaryMultiCallable[_hooks_message_pb2.PreferencesHaveChangedRequest, _hooks_message_pb2.PreferencesHaveChangedResponse] # type: ignore[assignment] """PreferencesHaveChanged is invoked after one or more of a user's preferences have changed. This is a notification hook. Go signature: PreferencesHaveChanged(c *Context, preferences []model.Preference) """ UserHasBeenCreated: _aio.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserHasBeenCreatedRequest, _hooks_user_channel_pb2.UserHasBeenCreatedResponse] # type: ignore[assignment] """=========================================================================== USER HOOKS =========================================================================== UserHasBeenCreated is invoked after a user was created. This is a notification hook - you cannot modify or reject the creation. Go signature: UserHasBeenCreated(c *Context, user *model.User) """ UserWillLogIn: _aio.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserWillLogInRequest, _hooks_user_channel_pb2.UserWillLogInResponse] # type: ignore[assignment] """UserWillLogIn is invoked before the login of the user is returned. Return a non-empty string to reject the login. If you don't need to reject the login event, see UserHasLoggedIn. Go signature: UserWillLogIn(c *Context, user *model.User) string """ UserHasLoggedIn: _aio.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserHasLoggedInRequest, _hooks_user_channel_pb2.UserHasLoggedInResponse] # type: ignore[assignment] """UserHasLoggedIn is invoked after a user has logged in. This is a notification hook - you cannot modify or reject the login. Go signature: UserHasLoggedIn(c *Context, user *model.User) """ UserHasBeenDeactivated: _aio.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserHasBeenDeactivatedRequest, _hooks_user_channel_pb2.UserHasBeenDeactivatedResponse] # type: ignore[assignment] """UserHasBeenDeactivated is invoked when a user is deactivated. This is a notification hook. Go signature: UserHasBeenDeactivated(c *Context, user *model.User) """ OnSAMLLogin: _aio.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.OnSAMLLoginRequest, _hooks_user_channel_pb2.OnSAMLLoginResponse] # type: ignore[assignment] """OnSAMLLogin is invoked after a successful SAML login. Return an error to reject the login. Go signature: OnSAMLLogin(c *Context, user *model.User, assertion *saml2.AssertionInfo) error """ ChannelHasBeenCreated: _aio.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.ChannelHasBeenCreatedRequest, _hooks_user_channel_pb2.ChannelHasBeenCreatedResponse] # type: ignore[assignment] """=========================================================================== CHANNEL AND TEAM HOOKS =========================================================================== ChannelHasBeenCreated is invoked after a channel has been created. This is a notification hook - you cannot modify or reject the creation. Go signature: ChannelHasBeenCreated(c *Context, channel *model.Channel) """ UserHasJoinedChannel: _aio.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserHasJoinedChannelRequest, _hooks_user_channel_pb2.UserHasJoinedChannelResponse] # type: ignore[assignment] """UserHasJoinedChannel is invoked after a user has joined a channel. This is a notification hook. The actor is optional (nil if self-join). Go signature: UserHasJoinedChannel(c *Context, channelMember *model.ChannelMember, actor *model.User) """ UserHasLeftChannel: _aio.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserHasLeftChannelRequest, _hooks_user_channel_pb2.UserHasLeftChannelResponse] # type: ignore[assignment] """UserHasLeftChannel is invoked after a user has left a channel. This is a notification hook. The actor is optional (nil if self-removal). Go signature: UserHasLeftChannel(c *Context, channelMember *model.ChannelMember, actor *model.User) """ UserHasJoinedTeam: _aio.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserHasJoinedTeamRequest, _hooks_user_channel_pb2.UserHasJoinedTeamResponse] # type: ignore[assignment] """UserHasJoinedTeam is invoked after a user has joined a team. This is a notification hook. The actor is optional (nil if self-join). Go signature: UserHasJoinedTeam(c *Context, teamMember *model.TeamMember, actor *model.User) """ UserHasLeftTeam: _aio.UnaryUnaryMultiCallable[_hooks_user_channel_pb2.UserHasLeftTeamRequest, _hooks_user_channel_pb2.UserHasLeftTeamResponse] # type: ignore[assignment] """UserHasLeftTeam is invoked after a user has left a team. This is a notification hook. The actor is optional (nil if self-removal). Go signature: UserHasLeftTeam(c *Context, teamMember *model.TeamMember, actor *model.User) """ ExecuteCommand: _aio.UnaryUnaryMultiCallable[_hooks_command_pb2.ExecuteCommandRequest, _hooks_command_pb2.ExecuteCommandResponse] # type: ignore[assignment] """=========================================================================== COMMAND HOOKS =========================================================================== ExecuteCommand executes a registered slash command. Go signature: ExecuteCommand(c *Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) """ OnWebSocketConnect: _aio.UnaryUnaryMultiCallable[_hooks_command_pb2.OnWebSocketConnectRequest, _hooks_command_pb2.OnWebSocketConnectResponse] # type: ignore[assignment] """=========================================================================== WEBSOCKET HOOKS =========================================================================== OnWebSocketConnect is invoked when a new WebSocket connection is opened. This is a notification hook with no Context parameter. Go signature: OnWebSocketConnect(webConnID, userID string) """ OnWebSocketDisconnect: _aio.UnaryUnaryMultiCallable[_hooks_command_pb2.OnWebSocketDisconnectRequest, _hooks_command_pb2.OnWebSocketDisconnectResponse] # type: ignore[assignment] """OnWebSocketDisconnect is invoked when a WebSocket connection is closed. This is a notification hook with no Context parameter. Go signature: OnWebSocketDisconnect(webConnID, userID string) """ WebSocketMessageHasBeenPosted: _aio.UnaryUnaryMultiCallable[_hooks_command_pb2.WebSocketMessageHasBeenPostedRequest, _hooks_command_pb2.WebSocketMessageHasBeenPostedResponse] # type: ignore[assignment] """WebSocketMessageHasBeenPosted is invoked when a WebSocket message is received. This is a notification hook with no Context parameter. Go signature: WebSocketMessageHasBeenPosted(webConnID, userID string, req *model.WebSocketRequest) """ OnPluginClusterEvent: _aio.UnaryUnaryMultiCallable[_hooks_command_pb2.OnPluginClusterEventRequest, _hooks_command_pb2.OnPluginClusterEventResponse] # type: ignore[assignment] """=========================================================================== CLUSTER HOOKS =========================================================================== OnPluginClusterEvent is invoked when an intra-cluster plugin event is received. Used for communication between plugin instances in a High-Availability cluster. This is a notification hook. Go signature: OnPluginClusterEvent(c *Context, ev model.PluginClusterEvent) """ OnSharedChannelsSyncMsg: _aio.UnaryUnaryMultiCallable[_hooks_command_pb2.OnSharedChannelsSyncMsgRequest, _hooks_command_pb2.OnSharedChannelsSyncMsgResponse] # type: ignore[assignment] """=========================================================================== SHARED CHANNELS HOOKS =========================================================================== OnSharedChannelsSyncMsg is invoked when a shared channels sync message is received. Plugins can use this to synchronize data with remote clusters. Go signature: OnSharedChannelsSyncMsg(msg *model.SyncMsg, rc *model.RemoteCluster) (model.SyncResponse, error) """ OnSharedChannelsPing: _aio.UnaryUnaryMultiCallable[_hooks_command_pb2.OnSharedChannelsPingRequest, _hooks_command_pb2.OnSharedChannelsPingResponse] # type: ignore[assignment] """OnSharedChannelsPing is invoked to check the health of the shared channels plugin. Return true if the plugin and upstream connections are healthy. Go signature: OnSharedChannelsPing(rc *model.RemoteCluster) bool """ OnSharedChannelsAttachmentSyncMsg: _aio.UnaryUnaryMultiCallable[_hooks_command_pb2.OnSharedChannelsAttachmentSyncMsgRequest, _hooks_command_pb2.OnSharedChannelsAttachmentSyncMsgResponse] # type: ignore[assignment] """OnSharedChannelsAttachmentSyncMsg is invoked when a file attachment sync message is received. Used to synchronize file attachments between shared channel participants. Go signature: OnSharedChannelsAttachmentSyncMsg(fi *model.FileInfo, post *model.Post, rc *model.RemoteCluster) error """ OnSharedChannelsProfileImageSyncMsg: _aio.UnaryUnaryMultiCallable[_hooks_command_pb2.OnSharedChannelsProfileImageSyncMsgRequest, _hooks_command_pb2.OnSharedChannelsProfileImageSyncMsgResponse] # type: ignore[assignment] """OnSharedChannelsProfileImageSyncMsg is invoked when a profile image sync message is received. Used to synchronize user profile images between shared channel participants. Go signature: OnSharedChannelsProfileImageSyncMsg(user *model.User, rc *model.RemoteCluster) error """ GenerateSupportData: _aio.UnaryUnaryMultiCallable[_hooks_command_pb2.GenerateSupportDataRequest, _hooks_command_pb2.GenerateSupportDataResponse] # type: ignore[assignment] """=========================================================================== SUPPORT HOOKS =========================================================================== GenerateSupportData is invoked when a Support Packet is generated. Plugins can include their own diagnostic data in the support packet. Go signature: GenerateSupportData(c *Context) ([]*model.FileData, error) """ ServeHTTP: _aio.StreamStreamMultiCallable[_hooks_http_pb2.ServeHTTPRequest, _hooks_http_pb2.ServeHTTPResponse] # type: ignore[assignment] """=========================================================================== HTTP STREAMING HOOKS (Phase 8) =========================================================================== ServeHTTP handles HTTP requests to /plugins/{plugin_id}. Uses bidirectional streaming for efficient large body transfer. Request flow (Go -> Python): - First message: init metadata (method, URL, headers) + optional first body chunk - Subsequent messages: body chunks until body_complete=true Response flow (Python -> Go): - First message: init metadata (status, headers) + optional first body chunk - Subsequent messages: body chunks until body_complete=true Cancellation: HTTP client disconnect propagates via gRPC context. Body chunks are 64KB by default (configurable). Go signature: ServeHTTP(c *Context, w http.ResponseWriter, r *http.Request) """ class PluginHooksServicer(metaclass=_abc_1.ABCMeta): """============================================================================== PLUGIN HOOKS SERVICE ============================================================================== This service defines the gRPC interface for invoking plugin hooks. The Go server implements this service's client to call into Python plugins. Python plugins implement this service's server to receive hook invocations. Direction: Server -> Plugin (server calls plugin hooks) ERROR HANDLING CONVENTION: -------------------------- For hooks whose Go signature returns `error`: - Errors are encoded in the response message's `error` field (AppError) - gRPC status codes are reserved for transport-level failures only For hooks whose Go signature returns nothing (void): - Response message has no `error` field - Hook failures are logged server-side but do not propagate HOOK GROUPS: ------------ This file imports and exposes RPCs for different hook categories: - hooks_lifecycle.proto: Lifecycle and system hooks (this plan: 03-01) - hooks_message.proto: Message hooks (planned: 03-02) - hooks_user_channel.proto: User and channel hooks (03-03) - hooks_command.proto: Command, WebSocket, cluster, shared channels hooks (03-04) ============================================================================== PluginHooks is the gRPC service for invoking plugin hooks. The server acts as the gRPC client, calling into the plugin process. The plugin acts as the gRPC server, implementing the hook handlers. =========================================================================== LIFECYCLE HOOKS =========================================================================== """ @_abc_1.abstractmethod def Implemented( self, request: _hooks_lifecycle_pb2.ImplementedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_lifecycle_pb2.ImplementedResponse, _abc.Awaitable[_hooks_lifecycle_pb2.ImplementedResponse]]: """Implemented returns the list of hooks that the plugin implements. Called during plugin startup to optimize hook dispatch. Plugins that don't implement this are assumed to implement all hooks. Go signature: Implemented() ([]string, error) """ @_abc_1.abstractmethod def OnActivate( self, request: _hooks_lifecycle_pb2.OnActivateRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_lifecycle_pb2.OnActivateResponse, _abc.Awaitable[_hooks_lifecycle_pb2.OnActivateResponse]]: """OnActivate is invoked when the plugin is activated. If an error is returned, the plugin will be terminated. The plugin will not receive hooks until after OnActivate returns without error. OnConfigurationChange will be called once before OnActivate. Go signature: OnActivate() error """ @_abc_1.abstractmethod def OnDeactivate( self, request: _hooks_lifecycle_pb2.OnDeactivateRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_lifecycle_pb2.OnDeactivateResponse, _abc.Awaitable[_hooks_lifecycle_pb2.OnDeactivateResponse]]: """OnDeactivate is invoked when the plugin is deactivated. This is the plugin's last chance to use the API. The plugin will be terminated shortly after this invocation. Go signature: OnDeactivate() error """ @_abc_1.abstractmethod def OnConfigurationChange( self, request: _hooks_lifecycle_pb2.OnConfigurationChangeRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_lifecycle_pb2.OnConfigurationChangeResponse, _abc.Awaitable[_hooks_lifecycle_pb2.OnConfigurationChangeResponse]]: """OnConfigurationChange is invoked when configuration changes may have been made. Any returned error is logged but does not stop the plugin. It is called once before OnActivate. Go signature: OnConfigurationChange() error """ @_abc_1.abstractmethod def OnInstall( self, request: _hooks_lifecycle_pb2.OnInstallRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_lifecycle_pb2.OnInstallResponse, _abc.Awaitable[_hooks_lifecycle_pb2.OnInstallResponse]]: """=========================================================================== SYSTEM HOOKS =========================================================================== OnInstall is invoked after the installation of a plugin as part of onboarding. It's called on every installation, not only once. Go signature: OnInstall(c *Context, event model.OnInstallEvent) error """ @_abc_1.abstractmethod def OnSendDailyTelemetry( self, request: _hooks_lifecycle_pb2.OnSendDailyTelemetryRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_lifecycle_pb2.OnSendDailyTelemetryResponse, _abc.Awaitable[_hooks_lifecycle_pb2.OnSendDailyTelemetryResponse]]: """OnSendDailyTelemetry is invoked when the server sends daily telemetry data. Plugins can use this to send their own telemetry metrics. Go signature: OnSendDailyTelemetry() """ @_abc_1.abstractmethod def RunDataRetention( self, request: _hooks_lifecycle_pb2.RunDataRetentionRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_lifecycle_pb2.RunDataRetentionResponse, _abc.Awaitable[_hooks_lifecycle_pb2.RunDataRetentionResponse]]: """RunDataRetention is invoked during a DataRetentionJob. Plugins should delete data older than their retention policy. Go signature: RunDataRetention(nowTime, batchSize int64) (int64, error) """ @_abc_1.abstractmethod def OnCloudLimitsUpdated( self, request: _hooks_lifecycle_pb2.OnCloudLimitsUpdatedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_lifecycle_pb2.OnCloudLimitsUpdatedResponse, _abc.Awaitable[_hooks_lifecycle_pb2.OnCloudLimitsUpdatedResponse]]: """OnCloudLimitsUpdated is invoked when cloud product limits change. For example, when plan tiers change affecting storage or message limits. Go signature: OnCloudLimitsUpdated(limits *model.ProductLimits) """ @_abc_1.abstractmethod def ConfigurationWillBeSaved( self, request: _hooks_lifecycle_pb2.ConfigurationWillBeSavedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_lifecycle_pb2.ConfigurationWillBeSavedResponse, _abc.Awaitable[_hooks_lifecycle_pb2.ConfigurationWillBeSavedResponse]]: """ConfigurationWillBeSaved is invoked before saving configuration to the backing store. An error can be returned to reject the operation. Additionally, a new config object can be returned to be stored in place of the provided one. Go signature: ConfigurationWillBeSaved(newCfg *model.Config) (*model.Config, error) """ @_abc_1.abstractmethod def MessageWillBePosted( self, request: _hooks_message_pb2.MessageWillBePostedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_message_pb2.MessageWillBePostedResponse, _abc.Awaitable[_hooks_message_pb2.MessageWillBePostedResponse]]: """=========================================================================== MESSAGE HOOKS =========================================================================== MessageWillBePosted is invoked when a message is posted before it is committed to the database. Use this to modify or reject posts before they are saved. Return values: - To allow unchanged: return nil post and empty string - To modify: return modified post and empty string - To reject: return nil post and rejection reason string - To dismiss silently: return nil post and "plugin.message_will_be_posted.dismiss_post" Go signature: MessageWillBePosted(c *Context, post *model.Post) (*model.Post, string) """ @_abc_1.abstractmethod def MessageWillBeUpdated( self, request: _hooks_message_pb2.MessageWillBeUpdatedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_message_pb2.MessageWillBeUpdatedResponse, _abc.Awaitable[_hooks_message_pb2.MessageWillBeUpdatedResponse]]: """MessageWillBeUpdated is invoked when a message is updated before it is committed to the database. Use this to modify or reject post updates. Return values: - To allow unchanged: return nil post and empty string - To modify: return modified post and empty string - To reject: return nil post and rejection reason (post stays unchanged) Go signature: MessageWillBeUpdated(c *Context, newPost, oldPost *model.Post) (*model.Post, string) """ @_abc_1.abstractmethod def MessageHasBeenPosted( self, request: _hooks_message_pb2.MessageHasBeenPostedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_message_pb2.MessageHasBeenPostedResponse, _abc.Awaitable[_hooks_message_pb2.MessageHasBeenPostedResponse]]: """MessageHasBeenPosted is invoked after the message has been committed to the database. This is a notification hook - you cannot modify or reject the post. Use MessageWillBePosted if you need to modify or reject. Go signature: MessageHasBeenPosted(c *Context, post *model.Post) """ @_abc_1.abstractmethod def MessageHasBeenUpdated( self, request: _hooks_message_pb2.MessageHasBeenUpdatedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_message_pb2.MessageHasBeenUpdatedResponse, _abc.Awaitable[_hooks_message_pb2.MessageHasBeenUpdatedResponse]]: """MessageHasBeenUpdated is invoked after a message update has been committed to the database. This is a notification hook - you cannot modify or reject the update. Use MessageWillBeUpdated if you need to modify or reject. Go signature: MessageHasBeenUpdated(c *Context, newPost, oldPost *model.Post) """ @_abc_1.abstractmethod def MessagesWillBeConsumed( self, request: _hooks_message_pb2.MessagesWillBeConsumedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_message_pb2.MessagesWillBeConsumedResponse, _abc.Awaitable[_hooks_message_pb2.MessagesWillBeConsumedResponse]]: """MessagesWillBeConsumed is invoked when messages are requested by a client before they are returned. Use this to filter or modify posts before delivery. Note: This hook has no Context parameter and no error return. Go signature: MessagesWillBeConsumed(posts []*model.Post) []*model.Post """ @_abc_1.abstractmethod def MessageHasBeenDeleted( self, request: _hooks_message_pb2.MessageHasBeenDeletedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_message_pb2.MessageHasBeenDeletedResponse, _abc.Awaitable[_hooks_message_pb2.MessageHasBeenDeletedResponse]]: """MessageHasBeenDeleted is invoked after a message has been deleted from the database. This is a notification hook - you cannot undo the deletion. Go signature: MessageHasBeenDeleted(c *Context, post *model.Post) """ @_abc_1.abstractmethod def FileWillBeUploaded( self, request: _hooks_message_pb2.FileWillBeUploadedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_message_pb2.FileWillBeUploadedResponse, _abc.Awaitable[_hooks_message_pb2.FileWillBeUploadedResponse]]: """FileWillBeUploaded is invoked when a file is uploaded before it is committed to storage. Use this to modify or reject file uploads. Note: Phase 8 will add streaming support. Currently uses bytes for file content. Return values: - To allow unchanged: return nil FileInfo, empty bytes, empty string - To modify: return modified FileInfo and/or content, empty string - To reject: return nil FileInfo, empty bytes, and rejection reason Go signature: FileWillBeUploaded(c *Context, info *model.FileInfo, file io.Reader, output io.Writer) (*model.FileInfo, string) """ @_abc_1.abstractmethod def ReactionHasBeenAdded( self, request: _hooks_message_pb2.ReactionHasBeenAddedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_message_pb2.ReactionHasBeenAddedResponse, _abc.Awaitable[_hooks_message_pb2.ReactionHasBeenAddedResponse]]: """ReactionHasBeenAdded is invoked after a reaction has been committed to the database. This is a notification hook. Go signature: ReactionHasBeenAdded(c *Context, reaction *model.Reaction) """ @_abc_1.abstractmethod def ReactionHasBeenRemoved( self, request: _hooks_message_pb2.ReactionHasBeenRemovedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_message_pb2.ReactionHasBeenRemovedResponse, _abc.Awaitable[_hooks_message_pb2.ReactionHasBeenRemovedResponse]]: """ReactionHasBeenRemoved is invoked after a reaction has been removed from the database. This is a notification hook. Go signature: ReactionHasBeenRemoved(c *Context, reaction *model.Reaction) """ @_abc_1.abstractmethod def NotificationWillBePushed( self, request: _hooks_message_pb2.NotificationWillBePushedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_message_pb2.NotificationWillBePushedResponse, _abc.Awaitable[_hooks_message_pb2.NotificationWillBePushedResponse]]: """NotificationWillBePushed is invoked before a push notification is sent to the push notification server. Use this to modify or reject push notifications. Note: This hook has no Context parameter. Return values: - To allow unchanged: return nil notification and empty string - To modify: return modified notification and empty string - To reject: return nil notification and rejection reason Go signature: NotificationWillBePushed(pushNotification *model.PushNotification, userID string) (*model.PushNotification, string) """ @_abc_1.abstractmethod def EmailNotificationWillBeSent( self, request: _hooks_message_pb2.EmailNotificationWillBeSentRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_message_pb2.EmailNotificationWillBeSentResponse, _abc.Awaitable[_hooks_message_pb2.EmailNotificationWillBeSentResponse]]: """EmailNotificationWillBeSent is invoked before an email notification is sent. Use this to customize email content or reject the notification. Note: Core identifiers (PostId, ChannelId, etc.) are immutable. Only content fields (subject, title, message, etc.) can be modified. Note: This hook has no Context parameter. Return values: - To allow unchanged: return nil content and empty string - To modify: return modified EmailNotificationContent and empty string - To reject: return nil content and rejection reason Go signature: EmailNotificationWillBeSent(emailNotification *model.EmailNotification) (*model.EmailNotificationContent, string) """ @_abc_1.abstractmethod def PreferencesHaveChanged( self, request: _hooks_message_pb2.PreferencesHaveChangedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_message_pb2.PreferencesHaveChangedResponse, _abc.Awaitable[_hooks_message_pb2.PreferencesHaveChangedResponse]]: """PreferencesHaveChanged is invoked after one or more of a user's preferences have changed. This is a notification hook. Go signature: PreferencesHaveChanged(c *Context, preferences []model.Preference) """ @_abc_1.abstractmethod def UserHasBeenCreated( self, request: _hooks_user_channel_pb2.UserHasBeenCreatedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_user_channel_pb2.UserHasBeenCreatedResponse, _abc.Awaitable[_hooks_user_channel_pb2.UserHasBeenCreatedResponse]]: """=========================================================================== USER HOOKS =========================================================================== UserHasBeenCreated is invoked after a user was created. This is a notification hook - you cannot modify or reject the creation. Go signature: UserHasBeenCreated(c *Context, user *model.User) """ @_abc_1.abstractmethod def UserWillLogIn( self, request: _hooks_user_channel_pb2.UserWillLogInRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_user_channel_pb2.UserWillLogInResponse, _abc.Awaitable[_hooks_user_channel_pb2.UserWillLogInResponse]]: """UserWillLogIn is invoked before the login of the user is returned. Return a non-empty string to reject the login. If you don't need to reject the login event, see UserHasLoggedIn. Go signature: UserWillLogIn(c *Context, user *model.User) string """ @_abc_1.abstractmethod def UserHasLoggedIn( self, request: _hooks_user_channel_pb2.UserHasLoggedInRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_user_channel_pb2.UserHasLoggedInResponse, _abc.Awaitable[_hooks_user_channel_pb2.UserHasLoggedInResponse]]: """UserHasLoggedIn is invoked after a user has logged in. This is a notification hook - you cannot modify or reject the login. Go signature: UserHasLoggedIn(c *Context, user *model.User) """ @_abc_1.abstractmethod def UserHasBeenDeactivated( self, request: _hooks_user_channel_pb2.UserHasBeenDeactivatedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_user_channel_pb2.UserHasBeenDeactivatedResponse, _abc.Awaitable[_hooks_user_channel_pb2.UserHasBeenDeactivatedResponse]]: """UserHasBeenDeactivated is invoked when a user is deactivated. This is a notification hook. Go signature: UserHasBeenDeactivated(c *Context, user *model.User) """ @_abc_1.abstractmethod def OnSAMLLogin( self, request: _hooks_user_channel_pb2.OnSAMLLoginRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_user_channel_pb2.OnSAMLLoginResponse, _abc.Awaitable[_hooks_user_channel_pb2.OnSAMLLoginResponse]]: """OnSAMLLogin is invoked after a successful SAML login. Return an error to reject the login. Go signature: OnSAMLLogin(c *Context, user *model.User, assertion *saml2.AssertionInfo) error """ @_abc_1.abstractmethod def ChannelHasBeenCreated( self, request: _hooks_user_channel_pb2.ChannelHasBeenCreatedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_user_channel_pb2.ChannelHasBeenCreatedResponse, _abc.Awaitable[_hooks_user_channel_pb2.ChannelHasBeenCreatedResponse]]: """=========================================================================== CHANNEL AND TEAM HOOKS =========================================================================== ChannelHasBeenCreated is invoked after a channel has been created. This is a notification hook - you cannot modify or reject the creation. Go signature: ChannelHasBeenCreated(c *Context, channel *model.Channel) """ @_abc_1.abstractmethod def UserHasJoinedChannel( self, request: _hooks_user_channel_pb2.UserHasJoinedChannelRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_user_channel_pb2.UserHasJoinedChannelResponse, _abc.Awaitable[_hooks_user_channel_pb2.UserHasJoinedChannelResponse]]: """UserHasJoinedChannel is invoked after a user has joined a channel. This is a notification hook. The actor is optional (nil if self-join). Go signature: UserHasJoinedChannel(c *Context, channelMember *model.ChannelMember, actor *model.User) """ @_abc_1.abstractmethod def UserHasLeftChannel( self, request: _hooks_user_channel_pb2.UserHasLeftChannelRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_user_channel_pb2.UserHasLeftChannelResponse, _abc.Awaitable[_hooks_user_channel_pb2.UserHasLeftChannelResponse]]: """UserHasLeftChannel is invoked after a user has left a channel. This is a notification hook. The actor is optional (nil if self-removal). Go signature: UserHasLeftChannel(c *Context, channelMember *model.ChannelMember, actor *model.User) """ @_abc_1.abstractmethod def UserHasJoinedTeam( self, request: _hooks_user_channel_pb2.UserHasJoinedTeamRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_user_channel_pb2.UserHasJoinedTeamResponse, _abc.Awaitable[_hooks_user_channel_pb2.UserHasJoinedTeamResponse]]: """UserHasJoinedTeam is invoked after a user has joined a team. This is a notification hook. The actor is optional (nil if self-join). Go signature: UserHasJoinedTeam(c *Context, teamMember *model.TeamMember, actor *model.User) """ @_abc_1.abstractmethod def UserHasLeftTeam( self, request: _hooks_user_channel_pb2.UserHasLeftTeamRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_user_channel_pb2.UserHasLeftTeamResponse, _abc.Awaitable[_hooks_user_channel_pb2.UserHasLeftTeamResponse]]: """UserHasLeftTeam is invoked after a user has left a team. This is a notification hook. The actor is optional (nil if self-removal). Go signature: UserHasLeftTeam(c *Context, teamMember *model.TeamMember, actor *model.User) """ @_abc_1.abstractmethod def ExecuteCommand( self, request: _hooks_command_pb2.ExecuteCommandRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_command_pb2.ExecuteCommandResponse, _abc.Awaitable[_hooks_command_pb2.ExecuteCommandResponse]]: """=========================================================================== COMMAND HOOKS =========================================================================== ExecuteCommand executes a registered slash command. Go signature: ExecuteCommand(c *Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) """ @_abc_1.abstractmethod def OnWebSocketConnect( self, request: _hooks_command_pb2.OnWebSocketConnectRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_command_pb2.OnWebSocketConnectResponse, _abc.Awaitable[_hooks_command_pb2.OnWebSocketConnectResponse]]: """=========================================================================== WEBSOCKET HOOKS =========================================================================== OnWebSocketConnect is invoked when a new WebSocket connection is opened. This is a notification hook with no Context parameter. Go signature: OnWebSocketConnect(webConnID, userID string) """ @_abc_1.abstractmethod def OnWebSocketDisconnect( self, request: _hooks_command_pb2.OnWebSocketDisconnectRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_command_pb2.OnWebSocketDisconnectResponse, _abc.Awaitable[_hooks_command_pb2.OnWebSocketDisconnectResponse]]: """OnWebSocketDisconnect is invoked when a WebSocket connection is closed. This is a notification hook with no Context parameter. Go signature: OnWebSocketDisconnect(webConnID, userID string) """ @_abc_1.abstractmethod def WebSocketMessageHasBeenPosted( self, request: _hooks_command_pb2.WebSocketMessageHasBeenPostedRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_command_pb2.WebSocketMessageHasBeenPostedResponse, _abc.Awaitable[_hooks_command_pb2.WebSocketMessageHasBeenPostedResponse]]: """WebSocketMessageHasBeenPosted is invoked when a WebSocket message is received. This is a notification hook with no Context parameter. Go signature: WebSocketMessageHasBeenPosted(webConnID, userID string, req *model.WebSocketRequest) """ @_abc_1.abstractmethod def OnPluginClusterEvent( self, request: _hooks_command_pb2.OnPluginClusterEventRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_command_pb2.OnPluginClusterEventResponse, _abc.Awaitable[_hooks_command_pb2.OnPluginClusterEventResponse]]: """=========================================================================== CLUSTER HOOKS =========================================================================== OnPluginClusterEvent is invoked when an intra-cluster plugin event is received. Used for communication between plugin instances in a High-Availability cluster. This is a notification hook. Go signature: OnPluginClusterEvent(c *Context, ev model.PluginClusterEvent) """ @_abc_1.abstractmethod def OnSharedChannelsSyncMsg( self, request: _hooks_command_pb2.OnSharedChannelsSyncMsgRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_command_pb2.OnSharedChannelsSyncMsgResponse, _abc.Awaitable[_hooks_command_pb2.OnSharedChannelsSyncMsgResponse]]: """=========================================================================== SHARED CHANNELS HOOKS =========================================================================== OnSharedChannelsSyncMsg is invoked when a shared channels sync message is received. Plugins can use this to synchronize data with remote clusters. Go signature: OnSharedChannelsSyncMsg(msg *model.SyncMsg, rc *model.RemoteCluster) (model.SyncResponse, error) """ @_abc_1.abstractmethod def OnSharedChannelsPing( self, request: _hooks_command_pb2.OnSharedChannelsPingRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_command_pb2.OnSharedChannelsPingResponse, _abc.Awaitable[_hooks_command_pb2.OnSharedChannelsPingResponse]]: """OnSharedChannelsPing is invoked to check the health of the shared channels plugin. Return true if the plugin and upstream connections are healthy. Go signature: OnSharedChannelsPing(rc *model.RemoteCluster) bool """ @_abc_1.abstractmethod def OnSharedChannelsAttachmentSyncMsg( self, request: _hooks_command_pb2.OnSharedChannelsAttachmentSyncMsgRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_command_pb2.OnSharedChannelsAttachmentSyncMsgResponse, _abc.Awaitable[_hooks_command_pb2.OnSharedChannelsAttachmentSyncMsgResponse]]: """OnSharedChannelsAttachmentSyncMsg is invoked when a file attachment sync message is received. Used to synchronize file attachments between shared channel participants. Go signature: OnSharedChannelsAttachmentSyncMsg(fi *model.FileInfo, post *model.Post, rc *model.RemoteCluster) error """ @_abc_1.abstractmethod def OnSharedChannelsProfileImageSyncMsg( self, request: _hooks_command_pb2.OnSharedChannelsProfileImageSyncMsgRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_command_pb2.OnSharedChannelsProfileImageSyncMsgResponse, _abc.Awaitable[_hooks_command_pb2.OnSharedChannelsProfileImageSyncMsgResponse]]: """OnSharedChannelsProfileImageSyncMsg is invoked when a profile image sync message is received. Used to synchronize user profile images between shared channel participants. Go signature: OnSharedChannelsProfileImageSyncMsg(user *model.User, rc *model.RemoteCluster) error """ @_abc_1.abstractmethod def GenerateSupportData( self, request: _hooks_command_pb2.GenerateSupportDataRequest, context: _ServicerContext, ) -> _typing.Union[_hooks_command_pb2.GenerateSupportDataResponse, _abc.Awaitable[_hooks_command_pb2.GenerateSupportDataResponse]]: """=========================================================================== SUPPORT HOOKS =========================================================================== GenerateSupportData is invoked when a Support Packet is generated. Plugins can include their own diagnostic data in the support packet. Go signature: GenerateSupportData(c *Context) ([]*model.FileData, error) """ @_abc_1.abstractmethod def ServeHTTP( self, request_iterator: _MaybeAsyncIterator[_hooks_http_pb2.ServeHTTPRequest], context: _ServicerContext, ) -> _typing.Union[_abc.Iterator[_hooks_http_pb2.ServeHTTPResponse], _abc.AsyncIterator[_hooks_http_pb2.ServeHTTPResponse]]: """=========================================================================== HTTP STREAMING HOOKS (Phase 8) =========================================================================== ServeHTTP handles HTTP requests to /plugins/{plugin_id}. Uses bidirectional streaming for efficient large body transfer. Request flow (Go -> Python): - First message: init metadata (method, URL, headers) + optional first body chunk - Subsequent messages: body chunks until body_complete=true Response flow (Python -> Go): - First message: init metadata (status, headers) + optional first body chunk - Subsequent messages: body chunks until body_complete=true Cancellation: HTTP client disconnect propagates via gRPC context. Body chunks are 64KB by default (configurable). Go signature: ServeHTTP(c *Context, w http.ResponseWriter, r *http.Request) """ def add_PluginHooksServicer_to_server(servicer: PluginHooksServicer, server: _typing.Union[_grpc.Server, _aio.Server]) -> None: ...