Skip to content

Commit

Permalink
updated v3 deleteReaction endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
saturninoabril committed Apr 18, 2017
1 parent 4b9e85c commit e9daaec
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions api/reaction.go
Expand Up @@ -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(c.Session.UserId, reaction.PostId, reaction.EmojiName)
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) {
Expand Down

0 comments on commit e9daaec

Please sign in to comment.