diff options
author | Saturnino Abril <saturnino.abril@gmail.com> | 2017-04-22 21:52:03 +0900 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-04-22 08:52:03 -0400 |
commit | ecb10ed62fdff179e34f82b0ff2569da8390f4ad (patch) | |
tree | e2405ed87a31cca42275b98a76e1312c0a1867eb /api/reaction.go | |
parent | e62afeace04e2abd23fa78a0a54e0a5d2e17e0b7 (diff) | |
download | chat-ecb10ed62fdff179e34f82b0ff2569da8390f4ad.tar.gz chat-ecb10ed62fdff179e34f82b0ff2569da8390f4ad.tar.bz2 chat-ecb10ed62fdff179e34f82b0ff2569da8390f4ad.zip |
APIv4 DELETE /users/{user_id}/posts/{post_id}/reactions/name (#6117)
* APIv4 DELETE /users/{user_id}/posts/{post_id}/reactions/name
* updated v3 deleteReaction endpoint
* update parameter of app.DeleteReactionForPost()
* update utils.IsValidAlphaNum, add utils.IsValidAlphaNumHyphenUnderscore, and add related tests
Diffstat (limited to 'api/reaction.go')
-rw-r--r-- | api/reaction.go | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/api/reaction.go b/api/reaction.go index 9def7274a..e6f7e845d 100644 --- a/api/reaction.go +++ b/api/reaction.go @@ -106,28 +106,13 @@ func deleteReaction(c *Context, w http.ResponseWriter, r *http.Request) { return } - var post *model.Post - - if result := <-app.Srv.Store.Post().Get(reaction.PostId); result.Err != nil { - c.Err = result.Err - return - } else if post = result.Data.(*model.PostList).Posts[postId]; post.ChannelId != channelId { - c.Err = model.NewLocAppError("deleteReaction", "api.reaction.delete_reaction.mismatched_channel_id.app_error", - nil, "channelId="+channelId+", post.ChannelId="+post.ChannelId+", postId="+postId) - c.Err.StatusCode = http.StatusBadRequest + err := app.DeleteReactionForPost(reaction) + if err != nil { + c.Err = err return } - if result := <-app.Srv.Store.Reaction().Delete(reaction); result.Err != nil { - c.Err = result.Err - return - } else { - go sendReactionEvent(model.WEBSOCKET_EVENT_REACTION_REMOVED, channelId, reaction, post) - - app.InvalidateCacheForReactions(reaction.PostId) - - ReturnStatusOK(w) - } + ReturnStatusOK(w) } func sendReactionEvent(event string, channelId string, reaction *model.Reaction, post *model.Post) { |