diff options
Diffstat (limited to 'plugin/hooks.go')
-rw-r--r-- | plugin/hooks.go | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/plugin/hooks.go b/plugin/hooks.go index e41081e48..68eca8ede 100644 --- a/plugin/hooks.go +++ b/plugin/hooks.go @@ -9,15 +9,32 @@ import ( "github.com/mattermost/mattermost-server/model" ) +// These assignments are part of the wire protocol. You can add more, but should not change existing +// assignments. Follow the naming convention of <HookName>Id as the autogenerated glue code depends on that. +const ( + OnActivateId = 0 + OnDeactivateId = 1 + ServeHTTPId = 2 + OnConfigurationChangeId = 3 + ExecuteCommandId = 4 + MessageWillBePostedId = 5 + MessageWillBeUpdatedId = 6 + MessageHasBeenPostedId = 7 + MessageHasBeenUpdatedId = 8 + TotalHooksId = iota +) + // Methods from the Hooks interface can be used by a plugin to respond to events. Methods are likely // to be added over time, and plugins are not expected to implement all of them. Instead, plugins // are expected to implement a subset of them and pass an instance to plugin/rpcplugin.Main, which // will take over execution of the process and add default behaviors for missing hooks. type Hooks interface { - // OnActivate is invoked when the plugin is activated. Implementations will usually want to save - // the api argument for later use. Loading configuration for the first time is also a commonly - // done here. - OnActivate(API) error + // OnActivate is invoked when the plugin is activated. + OnActivate() error + + // Implemented returns a list of hooks that are implmented by the plugin. + // Plugins do not need to provide an implementation. Any given will be ignored. + Implemented() ([]string, error) // OnDeactivate is invoked when the plugin is deactivated. This is the plugin's last chance to // use the API, and the plugin will be terminated shortly after this invocation. @@ -31,7 +48,7 @@ type Hooks interface { // // The Mattermost-User-Id header will be present if (and only if) the request is by an // authenticated user. - ServeHTTP(http.ResponseWriter, *http.Request) + ServeHTTP(w http.ResponseWriter, r *http.Request) // ExecuteCommand executes a command that has been previously registered via the RegisterCommand // API. |