events.ts raw
1 import { Pubkey, DomainEvent } from '../shared'
2 import { MuteVisibility } from './MuteList'
3
4 // Re-export DomainEvent for backward compatibility
5 export { DomainEvent }
6
7 // ============================================================================
8 // Follow List Events
9 // ============================================================================
10
11 /**
12 * Raised when a user follows another user
13 */
14 export class UserFollowed extends DomainEvent {
15 readonly eventType = 'social.user_followed'
16
17 constructor(
18 readonly actor: Pubkey,
19 readonly followed: Pubkey,
20 readonly relayHint?: string,
21 readonly petname?: string
22 ) {
23 super()
24 }
25 }
26
27 /**
28 * Raised when a user unfollows another user
29 */
30 export class UserUnfollowed extends DomainEvent {
31 readonly eventType = 'social.user_unfollowed'
32
33 constructor(
34 readonly actor: Pubkey,
35 readonly unfollowed: Pubkey
36 ) {
37 super()
38 }
39 }
40
41 /**
42 * Raised when a follow list is published
43 */
44 export class FollowListPublished extends DomainEvent {
45 readonly eventType = 'social.follow_list_published'
46
47 constructor(
48 readonly owner: Pubkey,
49 readonly followingCount: number
50 ) {
51 super()
52 }
53 }
54
55 // ============================================================================
56 // Mute List Events
57 // ============================================================================
58
59 /**
60 * Raised when a user mutes another user
61 */
62 export class UserMuted extends DomainEvent {
63 readonly eventType = 'social.user_muted'
64
65 constructor(
66 readonly actor: Pubkey,
67 readonly muted: Pubkey,
68 readonly visibility: MuteVisibility
69 ) {
70 super()
71 }
72 }
73
74 /**
75 * Raised when a user unmutes another user
76 */
77 export class UserUnmuted extends DomainEvent {
78 readonly eventType = 'social.user_unmuted'
79
80 constructor(
81 readonly actor: Pubkey,
82 readonly unmuted: Pubkey
83 ) {
84 super()
85 }
86 }
87
88 /**
89 * Raised when mute visibility is changed (public to private or vice versa)
90 */
91 export class MuteVisibilityChanged extends DomainEvent {
92 readonly eventType = 'social.mute_visibility_changed'
93
94 constructor(
95 readonly actor: Pubkey,
96 readonly target: Pubkey,
97 readonly from: MuteVisibility,
98 readonly to: MuteVisibility
99 ) {
100 super()
101 }
102 }
103
104 /**
105 * Raised when a mute list is published
106 */
107 export class MuteListPublished extends DomainEvent {
108 readonly eventType = 'social.mute_list_published'
109
110 constructor(
111 readonly owner: Pubkey,
112 readonly publicMuteCount: number,
113 readonly privateMuteCount: number
114 ) {
115 super()
116 }
117 }
118
119 // ============================================================================
120 // Event Types Union
121 // ============================================================================
122
123 /**
124 * Union type of all social domain events
125 */
126 export type SocialDomainEvent =
127 | UserFollowed
128 | UserUnfollowed
129 | FollowListPublished
130 | UserMuted
131 | UserUnmuted
132 | MuteVisibilityChanged
133 | MuteListPublished
134