MM-30558 - Add unreadReplies and unreadMentions to thread membership (#16304)

Этот коммит содержится в:
Eli Yukelzon
2020-12-06 10:02:53 +02:00
коммит произвёл GitHub
родитель cd9185fa23
Коммит 86e228b6c6
18 изменённых файлов: 653 добавлений и 187 удалений

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

@@ -190,12 +190,12 @@ func (c *Client4) GetUserRoute(userId string) string {
return fmt.Sprintf(c.GetUsersRoute()+"/%v", userId)
}
func (c *Client4) GetUserThreadsRoute(userId string) string {
return fmt.Sprintf(c.GetUsersRoute()+"/%v/threads", userId)
func (c *Client4) GetUserThreadsRoute(userID, teamID string) string {
return c.GetUserRoute(userID) + c.GetTeamRoute(teamID) + "/threads"
}
func (c *Client4) GetUserThreadRoute(userId, threadId string) string {
return fmt.Sprintf(c.GetUserThreadsRoute(userId)+"/%v", threadId)
func (c *Client4) GetUserThreadRoute(userId, teamId, threadId string) string {
return c.GetUserThreadsRoute(userId, teamId) + "/" + threadId
}
func (c *Client4) GetUserCategoryRoute(userID, teamID string) string {
@@ -5767,7 +5767,7 @@ func (c *Client4) ListImports() ([]string, *Response) {
return ArrayFromJson(r.Body), BuildResponse(r)
}
func (c *Client4) GetUserThreads(userId string, options GetUserThreadsOpts) (*Threads, *Response) {
func (c *Client4) GetUserThreads(userId, teamId string, options GetUserThreadsOpts) (*Threads, *Response) {
v := url.Values{}
if options.Since != 0 {
v.Set("since", fmt.Sprintf("%d", options.Since))
@@ -5785,7 +5785,7 @@ func (c *Client4) GetUserThreads(userId string, options GetUserThreadsOpts) (*Th
v.Set("deleted", "true")
}
url := c.GetUserThreadsRoute(userId)
url := c.GetUserThreadsRoute(userId, teamId)
if len(v) > 0 {
url += "?" + v.Encode()
}
@@ -5802,8 +5802,8 @@ func (c *Client4) GetUserThreads(userId string, options GetUserThreadsOpts) (*Th
return &threads, BuildResponse(r)
}
func (c *Client4) UpdateThreadsReadForUser(userId string, timestamp int64) *Response {
r, appErr := c.DoApiPut(fmt.Sprintf("%s/read/%d", c.GetUserThreadsRoute(userId), timestamp), "")
func (c *Client4) UpdateThreadsReadForUser(userId, teamId string) *Response {
r, appErr := c.DoApiPut(fmt.Sprintf("%s/read", c.GetUserThreadsRoute(userId, teamId)), "")
if appErr != nil {
return BuildErrorResponse(r, appErr)
}
@@ -5812,8 +5812,8 @@ func (c *Client4) UpdateThreadsReadForUser(userId string, timestamp int64) *Resp
return BuildResponse(r)
}
func (c *Client4) UpdateThreadReadForUser(userId, threadId string, timestamp int64) *Response {
r, appErr := c.DoApiPut(fmt.Sprintf("%s/read/%d", c.GetUserThreadRoute(userId, threadId), timestamp), "")
func (c *Client4) UpdateThreadReadForUser(userId, teamId, threadId string, timestamp int64) *Response {
r, appErr := c.DoApiPut(fmt.Sprintf("%s/read/%d", c.GetUserThreadRoute(userId, teamId, threadId), timestamp), "")
if appErr != nil {
return BuildErrorResponse(r, appErr)
}
@@ -5822,13 +5822,13 @@ func (c *Client4) UpdateThreadReadForUser(userId, threadId string, timestamp int
return BuildResponse(r)
}
func (c *Client4) UpdateThreadFollowForUser(userId, threadId string, state bool) *Response {
func (c *Client4) UpdateThreadFollowForUser(userId, teamId, threadId string, state bool) *Response {
var appErr *AppError
var r *http.Response
if state {
r, appErr = c.DoApiPut(c.GetUserThreadRoute(userId, threadId)+"/following", "")
r, appErr = c.DoApiPut(c.GetUserThreadRoute(userId, teamId, threadId)+"/following", "")
} else {
r, appErr = c.DoApiDelete(c.GetUserThreadRoute(userId, threadId) + "/following")
r, appErr = c.DoApiDelete(c.GetUserThreadRoute(userId, teamId, threadId) + "/following")
}
if appErr != nil {
return BuildErrorResponse(r, appErr)

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

@@ -16,17 +16,21 @@ type Thread struct {
}
type ThreadResponse struct {
PostId string `json:"id"`
ReplyCount int64 `json:"reply_count"`
LastReplyAt int64 `json:"last_reply_at"`
LastViewedAt int64 `json:"last_viewed_at"`
Participants []*User `json:"participants"`
Post *Post `json:"post"`
PostId string `json:"id"`
ReplyCount int64 `json:"reply_count"`
LastReplyAt int64 `json:"last_reply_at"`
LastViewedAt int64 `json:"last_viewed_at"`
Participants []*User `json:"participants"`
Post *Post `json:"post"`
UnreadReplies int64 `json:"unread_replies"`
UnreadMentions int64 `json:"unread_mentions"`
}
type Threads struct {
Total int64 `json:"total"`
Threads []*ThreadResponse `json:"threads"`
Total int64 `json:"total"`
TotalUnreadReplies int64 `json:"total_unread_replies"`
TotalUnreadMentions int64 `json:"total_unread_mentions"`
Threads []*ThreadResponse `json:"threads"`
}
type GetUserThreadsOpts struct {