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
Этот коммит содержится в:
Saturnino Abril
2017-04-22 21:52:03 +09:00
коммит произвёл Harrison Healey
родитель e62afeace0
Коммит ecb10ed62f
15 изменённых файлов: 460 добавлений и 38 удалений

Просмотреть файл

@@ -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) {