summaryrefslogtreecommitdiffstats
path: root/plugin/hooks.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-05-15 13:33:47 -0700
committerGitHub <noreply@github.com>2018-05-15 13:33:47 -0700
commitdf6a7f8b19e2381ee57f946d5b184185653b2ee1 (patch)
tree622ff6b13b23bf4506ea41eb010141930e143815 /plugin/hooks.go
parentfbbe1f7cefd52a27fd52893509b5365d275f9bee (diff)
downloadchat-df6a7f8b19e2381ee57f946d5b184185653b2ee1.tar.gz
chat-df6a7f8b19e2381ee57f946d5b184185653b2ee1.tar.bz2
chat-df6a7f8b19e2381ee57f946d5b184185653b2ee1.zip
MM-10249 Adding plugin ability to intercept posts before they reach the DB. (#8791)
* Adding plugin ability to intercept posts before they reach the DB. * s/envoked/invoked/
Diffstat (limited to 'plugin/hooks.go')
-rw-r--r--plugin/hooks.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/plugin/hooks.go b/plugin/hooks.go
index 814609e8c..e41081e48 100644
--- a/plugin/hooks.go
+++ b/plugin/hooks.go
@@ -36,4 +36,37 @@ type Hooks interface {
// ExecuteCommand executes a command that has been previously registered via the RegisterCommand
// API.
ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *model.AppError)
+
+ // MessageWillBePosted is invoked when a message is posted by a user before it is commited
+ // to the database. If you also want to act on edited posts, see MessageWillBeUpdated.
+ // Return values should be the modified post or nil if rejected and an explanation for the user.
+ //
+ // If you don't need to modify or reject posts, use MessageHasBeenPosted instead.
+ //
+ // Note that this method will be called for posts created by plugins, including the plugin that
+ // created the post.
+ MessageWillBePosted(post *model.Post) (*model.Post, string)
+
+ // MessageWillBeUpdated is invoked when a message is updated by a user before it is commited
+ // to the database. If you also want to act on new posts, see MessageWillBePosted.
+ // Return values should be the modified post or nil if rejected and an explanation for the user.
+ // On rejection, the post will be kept in its previous state.
+ //
+ // If you don't need to modify or rejected updated posts, use MessageHasBeenUpdated instead.
+ //
+ // Note that this method will be called for posts updated by plugins, including the plugin that
+ // updated the post.
+ MessageWillBeUpdated(newPost, oldPost *model.Post) (*model.Post, string)
+
+ // MessageHasBeenPosted is invoked after the message has been commited to the databse.
+ // If you need to modify or reject the post, see MessageWillBePosted
+ // Note that this method will be called for posts created by plugins, including the plugin that
+ // created the post.
+ MessageHasBeenPosted(post *model.Post)
+
+ // MessageHasBeenUpdated is invoked after a message is updated and has been updated in the databse.
+ // If you need to modify or reject the post, see MessageWillBeUpdated
+ // Note that this method will be called for posts created by plugins, including the plugin that
+ // created the post.
+ MessageHasBeenUpdated(newPost, oldPost *model.Post)
}