-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy paththread.go
More file actions
102 lines (80 loc) · 3.51 KB
/
thread.go
File metadata and controls
102 lines (80 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package stream_chat
import (
"context"
"net/http"
"time"
)
type QueryThreadsRequest struct {
User *User `json:"user,omitempty"`
UserID string `json:"user_id,omitempty"`
Filter map[string]any `json:"filter,omitempty"`
Sort *SortParamRequestList `json:"sort,omitempty"`
Watch *bool `json:"watch,omitempty"`
PagerRequest
}
type QueryThreadsResponse struct {
Threads []ThreadResponse `json:"threads"`
Response
PagerResponse
}
type ThreadResponse struct {
ChannelCID string `json:"channel_cid"`
Channel *Channel `json:"channel,omitempty"`
ParentMessageID string `json:"parent_message_id"`
ParentMessage *MessageResponse `json:"parent_message,omitempty"`
CreatedByUserID string `json:"created_by_user_id"`
CreatedBy *UsersResponse `json:"created_by,omitempty"`
ReplyCount int `json:"reply_count,omitempty"`
ParticipantCount int `json:"participant_count,omitempty"`
ActiveParticipantCount int `json:"active_participant_count,omitempty"`
Participants ThreadParticipants `json:"thread_participants,omitempty"`
LastMessageAt *time.Time `json:"last_message_at,omitempty"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
Title string `json:"title"`
Custom map[string]any `json:"custom"`
LatestReplies []MessageResponse `json:"latest_replies,omitempty"`
Read ChannelRead `json:"read,omitempty"`
Draft Draft
}
type Thread struct {
AppPK int `json:"app_pk"`
ChannelCID string `json:"channel_cid"`
Channel *Channel `json:"channel,omitempty"`
ParentMessageID string `json:"parent_message_id"`
ParentMessage *Message `json:"parent_message,omitempty"`
CreatedByUserID string `json:"created_by_user_id"`
CreatedBy *User `json:"created_by,omitempty"`
ReplyCount int `json:"reply_count,omitempty"`
ParticipantCount int `json:"participant_count,omitempty"`
ActiveParticipantCount int `json:"active_participant_count,omitempty"`
Participants ThreadParticipants `json:"thread_participants,omitempty"`
LastMessageAt time.Time `json:"last_message_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
Title string `json:"title"`
Custom map[string]any `json:"custom"`
}
type ThreadParticipant struct {
AppPK int `json:"app_pk"`
ChannelCID string `json:"channel_cid"`
LastThreadMessageAt *time.Time `json:"last_thread_message_at"`
ThreadID string `json:"thread_id,omitempty"`
UserID string `json:"user_id,omitempty"`
User *User `json:"user,omitempty"`
CreatedAt time.Time `json:"created_at"`
LeftThreadAt *time.Time `json:"left_thread_at,omitempty"`
LastReadAt time.Time `json:"last_read_at"`
Custom map[string]interface{} `json:"custom"`
}
type ThreadParticipants []*ThreadParticipant
func (c *Client) QueryThreads(ctx context.Context, query *QueryThreadsRequest) (*QueryThreadsResponse, error) {
var resp QueryThreadsResponse
err := c.makeRequest(ctx, http.MethodPost, "threads", nil, query, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}