-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy paththreadsubscription.go
More file actions
57 lines (51 loc) · 2.64 KB
/
Copy paththreadsubscription.go
File metadata and controls
57 lines (51 loc) · 2.64 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
package model
import (
"errors"
"time"
)
var ErrThreadSubscriptionNotFound = errors.New("thread subscription not found")
type ThreadSubscription struct {
ID string `json:"id" bson:"_id"`
ParentMessageID string `json:"parentMessageId" bson:"parentMessageId"`
RoomID string `json:"roomId" bson:"roomId"`
ThreadRoomID string `json:"threadRoomId" bson:"threadRoomId"`
UserID string `json:"userId" bson:"userId"`
UserAccount string `json:"userAccount" bson:"userAccount"`
// SiteID is the home site of the room that contains this thread — same
// semantic as Subscription.SiteID. Across cross-site federation it stays
// constant: every replica of a given subscription has the same SiteID
// regardless of which site stores the document.
SiteID string `json:"siteId" bson:"siteId"`
// Never add omitempty: unreadThreadsPipeline relies on BSON encoding nil as explicit null, not a missing field.
LastSeenAt *time.Time `json:"lastSeenAt" bson:"lastSeenAt"`
HasMention bool `json:"hasMention" bson:"hasMention"`
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"`
}
// ThreadUnreadSummaryRequest is the NATS request body for the per-site thread
// unread summary RPC. Filtered on userAccount (the key every thread_subscriptions
// query and index uses).
type ThreadUnreadSummaryRequest struct {
UserAccount string `json:"userAccount"`
}
// ThreadUnreadSummaryResponse is the per-site thread unread rollup for one user.
// LastMessageAt is UnixMilli; nil when the user has no threads on this site.
type ThreadUnreadSummaryResponse struct {
Unread bool `json:"unread"`
UnreadDirectMessage bool `json:"unreadDirectMessage"`
UnreadMention bool `json:"unreadMention"`
LastMessageAt *int64 `json:"lastMessageAt,omitempty"`
}
// ThreadUnreadAggregateResponse is the cross-site rollup the user-service
// aggregator returns to the client. The booleans are OR-merged across every
// federation site; LastMessageAt is the newest across sites (UnixMilli, nil when
// the user has no threads anywhere). UnavailableSites lists sites that failed to
// respond — their unread state is not reflected in this page and the booleans
// may understate reality until they recover.
type ThreadUnreadAggregateResponse struct {
Unread bool `json:"unread"`
UnreadDirectMessage bool `json:"unreadDirectMessage"`
UnreadMention bool `json:"unreadMention"`
LastMessageAt *int64 `json:"lastMessageAt,omitempty"`
UnavailableSites []string `json:"unavailableSites,omitempty"`
}