summaryrefslogtreecommitdiffstats
path: root/model/client4.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/client4.go')
-rw-r--r--model/client4.go14
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 {