diff options
author | Saturnino Abril <saturnino.abril@gmail.com> | 2017-04-19 05:15:15 +0900 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-04-18 16:15:15 -0400 |
commit | d2b86f1b8de4784baf578b611cf80779ccfa722a (patch) | |
tree | 076d56f2522c0d9580e04061db3cce99facce67b /model/client4.go | |
parent | 8aab290d10cc7cdd864cebbd463044abfa2d2aea (diff) | |
download | chat-d2b86f1b8de4784baf578b611cf80779ccfa722a.tar.gz chat-d2b86f1b8de4784baf578b611cf80779ccfa722a.tar.bz2 chat-d2b86f1b8de4784baf578b611cf80779ccfa722a.zip |
APIv4 POST /reactions (#6092)
* APIv4 POST /reactions
* update corresponding V3 endpoint
Diffstat (limited to 'model/client4.go')
-rw-r--r-- | model/client4.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go index ad3ff51a4..a7a3607e6 100644 --- a/model/client4.go +++ b/model/client4.go @@ -238,6 +238,10 @@ func (c *Client4) GetEmojiRoute(emojiId string) string { return fmt.Sprintf(c.GetEmojisRoute()+"/%v", emojiId) } +func (c *Client4) GetReactionsRoute() string { + return fmt.Sprintf("/reactions") +} + func (c *Client4) DoApiGet(url string, etag string) (*http.Response, *AppError) { return c.DoApiRequest(http.MethodGet, url, "", etag) } @@ -2374,6 +2378,16 @@ func (c *Client4) GetEmoji(emojiId string) (*Emoji, *Response) { // Reaction Section +// SaveReaction saves an emoji reaction for a post. Returns the saved reaction if successful, otherwise an error will be returned. +func (c *Client4) SaveReaction(reaction *Reaction) (*Reaction, *Response) { + if r, err := c.DoApiPost(c.GetReactionsRoute(), reaction.ToJson()); err != nil { + return nil, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return ReactionFromJson(r.Body), BuildResponse(r) + } +} + // GetReactions returns a list of reactions to a post. func (c *Client4) GetReactions(postId string) ([]*Reaction, *Response) { if r, err := c.DoApiGet(c.GetPostRoute(postId)+"/reactions", ""); err != nil { |