forked from bytebase/bytebase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinbox.go
More file actions
76 lines (63 loc) · 1.73 KB
/
Copy pathinbox.go
File metadata and controls
76 lines (63 loc) · 1.73 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
package api
import (
"encoding/json"
)
// InboxStatus is the status for inboxes.
type InboxStatus string
const (
// Unread is the inbox status for UNREAD.
Unread InboxStatus = "UNREAD"
// Read is the inbox status for READ.
Read InboxStatus = "READ"
)
func (e InboxStatus) String() string {
switch e {
case Unread:
return "UNREAD"
case Read:
return "READ"
}
return "UNKNOWN"
}
// Inbox is the API message for an inbox.
type Inbox struct {
ID int `jsonapi:"primary,inbox"`
// Domain specific fields
ReceiverID int `jsonapi:"attr,receiverId"`
Activity *Activity `jsonapi:"relation,activity"`
Status InboxStatus `jsonapi:"attr,status"`
}
// InboxCreate is the API message for creating an inbox.
type InboxCreate struct {
// Domain specific fields
ReceiverID int
ActivityID int
}
// InboxFind is the API message for finding inboxes.
type InboxFind struct {
ID *int
// Domain specific fields
ReceiverID *int
// If specified, then it will only fetch "UNREAD" item or "READ" item whose activity created after "CreatedAfterTs"
ReadCreatedAfterTs *int64
}
func (find *InboxFind) String() string {
str, err := json.Marshal(*find)
if err != nil {
return err.Error()
}
return string(str)
}
// InboxPatch is the API message for patching an inbox.
type InboxPatch struct {
ID int
// Domain specific fields
Status InboxStatus `jsonapi:"attr,status"`
}
// InboxSummary is the API message for inbox summary info.
// This is used by the frontend to render the inbox sidebar item without fetching the actual inbox items.
// This returns json instead of jsonapi since it't not dealing with a particular resource.
type InboxSummary struct {
HasUnread bool `json:"hasUnread"`
HasUnreadError bool `json:"hasUnreadError"`
}