2020-10-01 18:48:38 +03:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
|
// See LICENSE.txt for license information.
|
|
|
|
|
|
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Thread struct {
|
|
|
|
|
PostId string `json:"id"`
|
2020-10-30 17:00:21 +02:00
|
|
|
ChannelId string `json:"channel_id"`
|
2020-10-01 18:48:38 +03:00
|
|
|
ReplyCount int64 `json:"reply_count"`
|
|
|
|
|
LastReplyAt int64 `json:"last_reply_at"`
|
|
|
|
|
Participants StringArray `json:"participants"`
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-08 10:36:46 +02:00
|
|
|
type ThreadResponse struct {
|
2020-12-06 10:02:53 +02:00
|
|
|
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"`
|
2020-11-08 10:36:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Threads struct {
|
2020-12-06 10:02:53 +02:00
|
|
|
Total int64 `json:"total"`
|
2021-01-19 13:33:57 +02:00
|
|
|
TotalUnreadThreads int64 `json:"total_unread_threads"`
|
2020-12-06 10:02:53 +02:00
|
|
|
TotalUnreadMentions int64 `json:"total_unread_mentions"`
|
|
|
|
|
Threads []*ThreadResponse `json:"threads"`
|
2020-11-08 10:36:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type GetUserThreadsOpts struct {
|
|
|
|
|
// PageSize specifies the size of the returned chunk of results. Default = 30
|
|
|
|
|
PageSize uint64
|
|
|
|
|
|
|
|
|
|
// Extended will enrich the response with participant details. Default = false
|
|
|
|
|
Extended bool
|
|
|
|
|
|
|
|
|
|
// Deleted will specify that even deleted threads should be returned (For mobile sync). Default = false
|
|
|
|
|
Deleted bool
|
|
|
|
|
|
|
|
|
|
// Since filters the threads based on their LastUpdateAt timestamp.
|
|
|
|
|
Since uint64
|
2021-01-31 11:54:35 +02:00
|
|
|
|
2021-01-31 12:28:14 +02:00
|
|
|
// Before specifies thread id as a cursor for pagination and will return `PageSize` threads before the cursor
|
|
|
|
|
Before string
|
|
|
|
|
|
|
|
|
|
// After specifies thread id as a cursor for pagination and will return `PageSize` threads after the cursor
|
|
|
|
|
After string
|
|
|
|
|
|
2021-01-31 11:54:35 +02:00
|
|
|
// Unread will make sure that only threads with unread replies are returned
|
|
|
|
|
Unread bool
|
2021-07-22 10:24:20 -04:00
|
|
|
|
|
|
|
|
// 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
|
2020-11-08 10:36:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-01-28 18:07:39 +02:00
|
|
|
func (o *ThreadResponse) ToJson() string {
|
|
|
|
|
b, _ := json.Marshal(o)
|
|
|
|
|
return string(b)
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 16:49:00 +02:00
|
|
|
func ThreadResponseFromJson(s string) (*ThreadResponse, error) {
|
|
|
|
|
var t ThreadResponse
|
|
|
|
|
err := json.Unmarshal([]byte(s), &t)
|
|
|
|
|
return &t, err
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-08 10:36:46 +02:00
|
|
|
func (o *Threads) ToJson() string {
|
|
|
|
|
b, _ := json.Marshal(o)
|
|
|
|
|
return string(b)
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-01 18:48:38 +03:00
|
|
|
func (o *Thread) ToJson() string {
|
|
|
|
|
b, _ := json.Marshal(o)
|
|
|
|
|
return string(b)
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-20 11:00:52 +02:00
|
|
|
func ThreadFromJson(s string) (*Thread, error) {
|
|
|
|
|
var t Thread
|
|
|
|
|
err := json.Unmarshal([]byte(s), &t)
|
|
|
|
|
return &t, err
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-01 18:48:38 +03:00
|
|
|
func (o *Thread) Etag() string {
|
|
|
|
|
return Etag(o.PostId, o.LastReplyAt)
|
|
|
|
|
}
|
2020-10-15 18:01:16 +03:00
|
|
|
|
|
|
|
|
type ThreadMembership struct {
|
2020-12-01 17:20:23 +02:00
|
|
|
PostId string `json:"post_id"`
|
|
|
|
|
UserId string `json:"user_id"`
|
|
|
|
|
Following bool `json:"following"`
|
|
|
|
|
LastViewed int64 `json:"last_view_at"`
|
|
|
|
|
LastUpdated int64 `json:"last_update_at"`
|
|
|
|
|
UnreadMentions int64 `json:"unread_mentions"`
|
2020-10-15 18:01:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o *ThreadMembership) ToJson() string {
|
|
|
|
|
b, _ := json.Marshal(o)
|
|
|
|
|
return string(b)
|
|
|
|
|
}
|