summaryrefslogtreecommitdiffstats
path: root/api4/post.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-08-29 16:14:59 -0500
committerGitHub <noreply@github.com>2017-08-29 16:14:59 -0500
commit213a072b38d29d3c3ec8e150584685b1144a7d6a (patch)
tree1da10a494e49914b0f6641db79e7dcf8ad3886f6 /api4/post.go
parent59798c137584a0b7e008ec713b489929dd83a690 (diff)
downloadchat-213a072b38d29d3c3ec8e150584685b1144a7d6a.tar.gz
chat-213a072b38d29d3c3ec8e150584685b1144a7d6a.tar.bz2
chat-213a072b38d29d3c3ec8e150584685b1144a7d6a.zip
PLT-6403: Interactive messages (#7274)
* wip * finish first pass * requested changes * add DoPostAction to Client4
Diffstat (limited to 'api4/post.go')
-rw-r--r--api4/post.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/api4/post.go b/api4/post.go
index deaad1e1c..ea23e098b 100644
--- a/api4/post.go
+++ b/api4/post.go
@@ -27,6 +27,7 @@ func InitPost() {
BaseRoutes.Team.Handle("/posts/search", ApiSessionRequired(searchPosts)).Methods("POST")
BaseRoutes.Post.Handle("", ApiSessionRequired(updatePost)).Methods("PUT")
BaseRoutes.Post.Handle("/patch", ApiSessionRequired(patchPost)).Methods("PUT")
+ BaseRoutes.Post.Handle("/actions/{action_id:[A-Za-z0-9]+}", ApiSessionRequired(doPostAction)).Methods("POST")
BaseRoutes.Post.Handle("/pin", ApiSessionRequired(pinPost)).Methods("POST")
BaseRoutes.Post.Handle("/unpin", ApiSessionRequired(unpinPost)).Methods("POST")
}
@@ -428,3 +429,22 @@ func getFileInfosForPost(c *Context, w http.ResponseWriter, r *http.Request) {
w.Write([]byte(model.FileInfosToJson(infos)))
}
}
+
+func doPostAction(c *Context, w http.ResponseWriter, r *http.Request) {
+ c.RequirePostId().RequireActionId()
+ if c.Err != nil {
+ return
+ }
+
+ if !app.SessionHasPermissionToChannelByPost(c.Session, c.Params.PostId, model.PERMISSION_READ_CHANNEL) {
+ c.SetPermissionError(model.PERMISSION_READ_CHANNEL)
+ return
+ }
+
+ if err := app.DoPostAction(c.Params.PostId, c.Params.ActionId, c.Session.UserId); err != nil {
+ c.Err = err
+ return
+ }
+
+ ReturnStatusOK(w)
+}