1// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2// See LICENSE.txt for license information. 3 4package model 5 6import ( 7 "encoding/json" 8) 9 10type Thread struct { 11 PostId string `json:"id"` 12 ChannelId string `json:"channel_id"` 13 ReplyCount int64 `json:"reply_count"` 14 LastReplyAt int64 `json:"last_reply_at"` 15 Participants StringArray `json:"participants"` 16} 17 18type ThreadResponse struct { 19 PostId string `json:"id"` 20 ReplyCount int64 `json:"reply_count"` 21 LastReplyAt int64 `json:"last_reply_at"` 22 LastViewedAt int64 `json:"last_viewed_at"` 23 Participants []*User `json:"participants"` 24 Post *Post `json:"post"` 25} 26 27type Threads struct { 28 Total int64 `json:"total"` 29 Threads []*ThreadResponse `json:"threads"` 30} 31 32type GetUserThreadsOpts struct { 33 // Page specifies which part of the results to return, by PageSize. Default = 0 34 Page uint64 35 36 // PageSize specifies the size of the returned chunk of results. Default = 30 37 PageSize uint64 38 39 // Extended will enrich the response with participant details. Default = false 40 Extended bool 41 42 // Deleted will specify that even deleted threads should be returned (For mobile sync). Default = false 43 Deleted bool 44 45 // Since filters the threads based on their LastUpdateAt timestamp. 46 Since uint64 47} 48 49func (o *Threads) ToJson() string { 50 b, _ := json.Marshal(o) 51 return string(b) 52} 53 54func (o *Thread) ToJson() string { 55 b, _ := json.Marshal(o) 56 return string(b) 57} 58 59func (o *Thread) Etag() string { 60 return Etag(o.PostId, o.LastReplyAt) 61} 62 63type ThreadMembership struct { 64 PostId string `json:"post_id"` 65 UserId string `json:"user_id"` 66 Following bool `json:"following"` 67 LastViewed int64 `json:"last_view_at"` 68 LastUpdated int64 `json:"last_update_at"` 69 UnreadMentions int64 `json:"unread_mentions"` 70} 71 72func (o *ThreadMembership) ToJson() string { 73 b, _ := json.Marshal(o) 74 return string(b) 75} 76