diff options
Diffstat (limited to 'api')
-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) { |