summaryrefslogtreecommitdiffstats
path: root/model/client4.go
diff options
context:
space:
mode:
authorAndrei Stanciu <andrei.stanciu@geminisols.ro>2017-02-28 17:47:30 +0200
committerGeorge Goldberg <george@gberg.me>2017-02-28 15:47:30 +0000
commit25b9b7d26b8738343d269c83031ba5a5408d0d58 (patch)
tree7f70c50bfdf9fe588268426005bb6305f6a074a7 /model/client4.go
parentb0410615b8206ea2706312a9f413785d86134f6d (diff)
downloadchat-25b9b7d26b8738343d269c83031ba5a5408d0d58.tar.gz
chat-25b9b7d26b8738343d269c83031ba5a5408d0d58.tar.bz2
chat-25b9b7d26b8738343d269c83031ba5a5408d0d58.zip
ApiV4: GET /users/{user_id}/teams/unread (#5539)
Diffstat (limited to 'model/client4.go')
-rw-r--r--model/client4.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go
index 0ccb94009..8d2423ad9 100644
--- a/model/client4.go
+++ b/model/client4.go
@@ -10,6 +10,7 @@ import (
"io/ioutil"
"mime/multipart"
"net/http"
+ "net/url"
"strconv"
"strings"
)
@@ -483,6 +484,23 @@ func (c *Client4) RevokeSession(userId, sessionId string) (bool, *Response) {
}
}
+// getTeamsUnreadForUser will return an array with TeamUnread objects that contain the amount of
+// unread messages and mentions the current user has for the teams it belongs to.
+// An optional team ID can be set to exclude that team from the results. Must be authenticated.
+func (c *Client4) GetTeamsUnreadForUser(userId, teamIdToExclude string) ([]*TeamUnread, *Response) {
+ optional := ""
+ if teamIdToExclude != "" {
+ optional += fmt.Sprintf("?exclude_team=%s", url.QueryEscape(teamIdToExclude))
+ }
+
+ if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/teams/unread"+optional, ""); err != nil {
+ return nil, &Response{StatusCode: r.StatusCode, Error: err}
+ } else {
+ defer closeBody(r)
+ return TeamsUnreadFromJson(r.Body), BuildResponse(r)
+ }
+}
+
// GetAudits returns a list of audit based on the provided user id string.
func (c *Client4) GetAudits(userId string, page int, perPage int, etag string) (Audits, *Response) {
query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)