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
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
e62afeace0
Коммит
ecb10ed62f
@@ -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)
|
||||
|
||||
Ссылка в новой задаче
Block a user