diff options
Diffstat (limited to 'app/reaction.go')
-rw-r--r-- | app/reaction.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/reaction.go b/app/reaction.go index eb542286f..cc57e1c4c 100644 --- a/app/reaction.go +++ b/app/reaction.go @@ -34,6 +34,23 @@ func GetReactionsForPost(postId string) ([]*model.Reaction, *model.AppError) { } } +func DeleteReactionForPost(reaction *model.Reaction) *model.AppError { + post, err := GetSinglePost(reaction.PostId) + if err != nil { + return err + } + + if result := <-Srv.Store.Reaction().Delete(reaction); result.Err != nil { + return result.Err + } else { + go sendReactionEvent(model.WEBSOCKET_EVENT_REACTION_REMOVED, reaction, post) + + InvalidateCacheForReactions(reaction.PostId) + } + + return nil +} + func sendReactionEvent(event string, reaction *model.Reaction, post *model.Post) { // send out that a reaction has been added/removed message := model.NewWebSocketEvent(event, "", post.ChannelId, "", nil) |