MM-35392 Load thread unreads for other teams on app load (#17944)

* Add ability to include thread unreads in team unreads api response

* Do not include GMs/DMs in team unreads for threads

* Fix bad merge
Этот коммит содержится в:
Joram Wilander
2021-07-22 10:24:20 -04:00
коммит произвёл GitHub
родитель 04ef406bd6
Коммит a0cc420e2a
11 изменённых файлов: 176 добавлений и 130 удалений

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

@@ -1445,14 +1445,20 @@ func (c *Client4) AttachDeviceId(deviceId 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) {
var optional string
// An optional team ID can be set to exclude that team from the results.
// An optional boolean can be set to include collapsed thread unreads. Must be authenticated.
func (c *Client4) GetTeamsUnreadForUser(userId, teamIdToExclude string, includeCollapsedThreads bool) ([]*TeamUnread, *Response) {
query := url.Values{}
if teamIdToExclude != "" {
optional += fmt.Sprintf("?exclude_team=%s", url.QueryEscape(teamIdToExclude))
query.Set("exclude_team", teamIdToExclude)
}
r, err := c.DoApiGet(c.GetUserRoute(userId)+"/teams/unread"+optional, "")
if includeCollapsedThreads {
query.Set("include_collapsed_threads", "true")
}
r, err := c.DoApiGet(c.GetUserRoute(userId)+"/teams/unread?"+query.Encode(), "")
if err != nil {
return nil, BuildErrorResponse(r, err)
}

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

@@ -31,11 +31,13 @@ type TeamMember struct {
//msgp:ignore TeamUnread
type TeamUnread struct {
TeamId string `json:"team_id"`
MsgCount int64 `json:"msg_count"`
MentionCount int64 `json:"mention_count"`
MentionCountRoot int64 `json:"mention_count_root"`
MsgCountRoot int64 `json:"msg_count_root"`
TeamId string `json:"team_id"`
MsgCount int64 `json:"msg_count"`
MentionCount int64 `json:"mention_count"`
MentionCountRoot int64 `json:"mention_count_root"`
MsgCountRoot int64 `json:"msg_count_root"`
ThreadCount int64 `json:"thread_count"`
ThreadMentionCount int64 `json:"thread_mention_count"`
}
//msgp:ignore TeamMemberForExport

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

@@ -54,6 +54,12 @@ type GetUserThreadsOpts struct {
// Unread will make sure that only threads with unread replies are returned
Unread bool
// TotalsOnly will not fetch any threads and just fetch the total counts
TotalsOnly bool
// TeamOnly will only fetch threads and unreads for the specified team and excludes DMs/GMs
TeamOnly bool
}
func (o *ThreadResponse) ToJson() string {