-
Notifications
You must be signed in to change notification settings - Fork 643
/
Copy pathmessages.ts
92 lines (77 loc) · 1.59 KB
/
messages.ts
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
// Below specific to message dispatcher
import { CID } from 'multiformats/cid'
import { AtUri } from '@atproto/uri'
export type IndexRecord = {
type: 'index_record'
uri: AtUri
cid: CID
obj: unknown
timestamp: string
}
export type DeleteRecord = {
type: 'delete_record'
uri: AtUri
cascading: boolean
}
export type DeleteRepo = {
type: 'delete_repo'
did: string
}
export const indexRecord = (
uri: AtUri,
cid: CID,
obj: unknown,
timestamp: string,
): IndexRecord => ({
type: 'index_record',
uri,
cid,
obj,
timestamp,
})
export const deleteRecord = (uri: AtUri, cascading: boolean): DeleteRecord => ({
type: 'delete_record',
uri,
cascading,
})
export const deleteRepo = (did: string): DeleteRepo => ({
type: 'delete_repo',
did,
})
// Below specific to message queue
export type CreateNotification = NotificationInfo & {
type: 'create_notification'
}
export type NotificationInfo = {
userDid: string
author: string
recordUri: string
recordCid: string
reason: NotificationReason
reasonSubject?: string
}
export type NotificationReason =
| 'vote'
| 'assertion'
| 'repost'
| 'follow'
| 'invite'
| 'mention'
| 'reply'
export type DeleteNotifications = {
type: 'delete_notifications'
recordUri: string
}
export type Message = CreateNotification | DeleteNotifications
export const createNotification = (
notif: NotificationInfo,
): CreateNotification => ({
type: 'create_notification',
...notif,
})
export const deleteNotifications = (
recordUri: string,
): DeleteNotifications => ({
type: 'delete_notifications',
recordUri,
})