diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-09-02 12:50:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-02 12:50:15 -0400 |
commit | f32eb525f3fa0828a23f589d765c267e3b2aea86 (patch) | |
tree | d4b76aecf89143029af080b3e1b4d87398e0adc5 /model/client.go | |
parent | eb0111f6bbe2b0bf160a674dfe1b4d089f905cb9 (diff) | |
download | chat-f32eb525f3fa0828a23f589d765c267e3b2aea86.tar.gz chat-f32eb525f3fa0828a23f589d765c267e3b2aea86.tar.bz2 chat-f32eb525f3fa0828a23f589d765c267e3b2aea86.zip |
Do not send push notifications for channels being actively viewed (#3931)
Diffstat (limited to 'model/client.go')
-rw-r--r-- | model/client.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/model/client.go b/model/client.go index f43e5ad79..2c3fb5aca 100644 --- a/model/client.go +++ b/model/client.go @@ -1140,8 +1140,13 @@ func (c *Client) RemoveChannelMember(id, user_id string) (*Result, *AppError) { } } -func (c *Client) UpdateLastViewedAt(channelId string) (*Result, *AppError) { - if r, err := c.DoApiPost(c.GetChannelRoute(channelId)+"/update_last_viewed_at", ""); err != nil { +// UpdateLastViewedAt will mark a channel as read. +// The channelId indicates the channel to mark as read. If active is true, push notifications +// will be cleared if there are unread messages. The default for active is true. +func (c *Client) UpdateLastViewedAt(channelId string, active bool) (*Result, *AppError) { + data := make(map[string]interface{}) + data["active"] = active + if r, err := c.DoApiPost(c.GetChannelRoute(channelId)+"/update_last_viewed_at", StringInterfaceToJson(data)); err != nil { return nil, err } else { defer closeBody(r) @@ -1463,6 +1468,21 @@ func (c *Client) GetStatuses() (*Result, *AppError) { } } +// SetActiveChannel sets the the channel id the user is currently viewing. +// The channelId key is required but the value can be blank. Returns standard +// response. +func (c *Client) SetActiveChannel(channelId string) (*Result, *AppError) { + data := map[string]string{} + data["channel_id"] = channelId + if r, err := c.DoApiPost("/users/status/set_active_channel", MapToJson(data)); err != nil { + return nil, err + } else { + defer closeBody(r) + return &Result{r.Header.Get(HEADER_REQUEST_ID), + r.Header.Get(HEADER_ETAG_SERVER), MapFromJson(r.Body)}, nil + } +} + func (c *Client) GetMyTeam(etag string) (*Result, *AppError) { if r, err := c.DoApiGet(c.GetTeamRoute()+"/me", "", etag); err != nil { return nil, err |