events.ts raw
1 import { Pubkey, EventId, DomainEvent } from '../shared'
2
3 // ============================================================================
4 // Bookmark Events
5 // ============================================================================
6
7 /**
8 * Raised when an event is bookmarked
9 */
10 export class EventBookmarked extends DomainEvent {
11 readonly eventType = 'content.event_bookmarked'
12
13 constructor(
14 readonly actor: Pubkey,
15 readonly bookmarkedEventId: string,
16 readonly bookmarkType: 'event' | 'replaceable'
17 ) {
18 super()
19 }
20 }
21
22 /**
23 * Raised when an event is removed from bookmarks
24 */
25 export class EventUnbookmarked extends DomainEvent {
26 readonly eventType = 'content.event_unbookmarked'
27
28 constructor(
29 readonly actor: Pubkey,
30 readonly unbookmarkedEventId: string
31 ) {
32 super()
33 }
34 }
35
36 /**
37 * Raised when a bookmark list is published
38 */
39 export class BookmarkListPublished extends DomainEvent {
40 readonly eventType = 'content.bookmark_list_published'
41
42 constructor(
43 readonly owner: Pubkey,
44 readonly bookmarkCount: number
45 ) {
46 super()
47 }
48 }
49
50 // ============================================================================
51 // Pin Events
52 // ============================================================================
53
54 /**
55 * Raised when a note is pinned
56 */
57 export class NotePinned extends DomainEvent {
58 readonly eventType = 'content.note_pinned'
59
60 constructor(
61 readonly actor: Pubkey,
62 readonly pinnedEventId: EventId
63 ) {
64 super()
65 }
66 }
67
68 /**
69 * Raised when a note is unpinned
70 */
71 export class NoteUnpinned extends DomainEvent {
72 readonly eventType = 'content.note_unpinned'
73
74 constructor(
75 readonly actor: Pubkey,
76 readonly unpinnedEventId: string
77 ) {
78 super()
79 }
80 }
81
82 /**
83 * Raised when old pins are removed due to limit
84 */
85 export class PinsLimitExceeded extends DomainEvent {
86 readonly eventType = 'content.pins_limit_exceeded'
87
88 constructor(
89 readonly actor: Pubkey,
90 readonly removedEventIds: string[]
91 ) {
92 super()
93 }
94 }
95
96 /**
97 * Raised when a pin list is published
98 */
99 export class PinListPublished extends DomainEvent {
100 readonly eventType = 'content.pin_list_published'
101
102 constructor(
103 readonly owner: Pubkey,
104 readonly pinCount: number
105 ) {
106 super()
107 }
108 }
109
110 // ============================================================================
111 // Reaction Events
112 // ============================================================================
113
114 /**
115 * Raised when a reaction is added to content
116 */
117 export class ReactionAdded extends DomainEvent {
118 readonly eventType = 'content.reaction_added'
119
120 constructor(
121 readonly actor: Pubkey,
122 readonly targetEventId: EventId,
123 readonly targetAuthor: Pubkey,
124 readonly emoji: string,
125 readonly isLike: boolean
126 ) {
127 super()
128 }
129 }
130
131 // ============================================================================
132 // Repost Events
133 // ============================================================================
134
135 /**
136 * Raised when content is reposted
137 */
138 export class ContentReposted extends DomainEvent {
139 readonly eventType = 'content.reposted'
140
141 constructor(
142 readonly actor: Pubkey,
143 readonly originalEventId: EventId,
144 readonly originalAuthor: Pubkey
145 ) {
146 super()
147 }
148 }
149
150 // ============================================================================
151 // Event Types Union
152 // ============================================================================
153
154 /**
155 * Union type of all content domain events
156 */
157 export type ContentDomainEvent =
158 | EventBookmarked
159 | EventUnbookmarked
160 | BookmarkListPublished
161 | NotePinned
162 | NoteUnpinned
163 | PinsLimitExceeded
164 | PinListPublished
165 | ReactionAdded
166 | ContentReposted
167