@wopr-network/platform-core 1.54.0 → 1.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,8 +11,14 @@ export class NotificationService {
11
11
  constructor(
12
12
  private readonly queue: INotificationQueueRepository,
13
13
  private readonly appBaseUrl: string,
14
+ private readonly brandName: string = "WOPR",
14
15
  ) {}
15
16
 
17
+ /** Enqueue with brandName injected into every data bag. */
18
+ private enqueue(tenantId: string, template: string, data: Record<string, unknown>): void {
19
+ this.queue.enqueue(tenantId, template, { ...data, brandName: this.brandName });
20
+ }
21
+
16
22
  private creditsUrl(): string {
17
23
  return `${this.appBaseUrl}/billing/credits`;
18
24
  }
@@ -22,7 +28,7 @@ export class NotificationService {
22
28
  // ---------------------------------------------------------------------------
23
29
 
24
30
  notifyLowBalance(tenantId: string, email: string, balanceDollars: string, estimatedDays: number): void {
25
- this.queue.enqueue(tenantId, "low-balance", {
31
+ this.enqueue(tenantId, "low-balance", {
26
32
  email,
27
33
  balanceDollars,
28
34
  estimatedDaysRemaining: estimatedDays,
@@ -31,14 +37,14 @@ export class NotificationService {
31
37
  }
32
38
 
33
39
  notifyCreditsDepeleted(tenantId: string, email: string): void {
34
- this.queue.enqueue(tenantId, "credits-depleted", {
40
+ this.enqueue(tenantId, "credits-depleted", {
35
41
  email,
36
42
  creditsUrl: this.creditsUrl(),
37
43
  });
38
44
  }
39
45
 
40
46
  notifyGracePeriodStart(tenantId: string, email: string, balanceDollars: string, graceDays: number): void {
41
- this.queue.enqueue(tenantId, "grace-period-start", {
47
+ this.enqueue(tenantId, "grace-period-start", {
42
48
  email,
43
49
  balanceDollars,
44
50
  graceDays,
@@ -47,14 +53,14 @@ export class NotificationService {
47
53
  }
48
54
 
49
55
  notifyGracePeriodWarning(tenantId: string, email: string): void {
50
- this.queue.enqueue(tenantId, "grace-period-warning", {
56
+ this.enqueue(tenantId, "grace-period-warning", {
51
57
  email,
52
58
  creditsUrl: this.creditsUrl(),
53
59
  });
54
60
  }
55
61
 
56
62
  notifyAutoSuspended(tenantId: string, email: string, reason: string): void {
57
- this.queue.enqueue(tenantId, "auto-suspended", {
63
+ this.enqueue(tenantId, "auto-suspended", {
58
64
  email,
59
65
  reason,
60
66
  creditsUrl: this.creditsUrl(),
@@ -62,7 +68,7 @@ export class NotificationService {
62
68
  }
63
69
 
64
70
  notifyAutoTopUpSuccess(tenantId: string, email: string, amountDollars: string, newBalanceDollars: string): void {
65
- this.queue.enqueue(tenantId, "auto-topup-success", {
71
+ this.enqueue(tenantId, "auto-topup-success", {
66
72
  email,
67
73
  amountDollars,
68
74
  newBalanceDollars,
@@ -71,14 +77,14 @@ export class NotificationService {
71
77
  }
72
78
 
73
79
  notifyAutoTopUpFailed(tenantId: string, email: string): void {
74
- this.queue.enqueue(tenantId, "auto-topup-failed", {
80
+ this.enqueue(tenantId, "auto-topup-failed", {
75
81
  email,
76
82
  creditsUrl: this.creditsUrl(),
77
83
  });
78
84
  }
79
85
 
80
86
  notifyAffiliateCreditMatch(tenantId: string, email: string, amountDollars: string): void {
81
- this.queue.enqueue(tenantId, "affiliate-credit-match", {
87
+ this.enqueue(tenantId, "affiliate-credit-match", {
82
88
  email,
83
89
  amountDollars,
84
90
  creditsUrl: this.creditsUrl(),
@@ -92,7 +98,7 @@ export class NotificationService {
92
98
  amountDollars: string,
93
99
  reason: string,
94
100
  ): void {
95
- this.queue.enqueue(tenantId, "dispute-created", {
101
+ this.enqueue(tenantId, "dispute-created", {
96
102
  email,
97
103
  disputeId,
98
104
  amountDollars,
@@ -102,7 +108,7 @@ export class NotificationService {
102
108
  }
103
109
 
104
110
  notifyDisputeWon(tenantId: string, email: string, disputeId: string, amountDollars: string): void {
105
- this.queue.enqueue(tenantId, "dispute-won", {
111
+ this.enqueue(tenantId, "dispute-won", {
106
112
  email,
107
113
  disputeId,
108
114
  amountDollars,
@@ -111,7 +117,7 @@ export class NotificationService {
111
117
  }
112
118
 
113
119
  notifyDisputeLost(tenantId: string, email: string, disputeId: string, amountDollars: string): void {
114
- this.queue.enqueue(tenantId, "dispute-lost", {
120
+ this.enqueue(tenantId, "dispute-lost", {
115
121
  email,
116
122
  disputeId,
117
123
  amountDollars,
@@ -125,7 +131,7 @@ export class NotificationService {
125
131
  currentSpendDollars: string,
126
132
  alertAtDollars: string,
127
133
  ): void {
128
- this.queue.enqueue(tenantId, "spend-alert", {
134
+ this.enqueue(tenantId, "spend-alert", {
129
135
  email,
130
136
  currentSpendDollars,
131
137
  alertAtDollars,
@@ -134,7 +140,7 @@ export class NotificationService {
134
140
  }
135
141
 
136
142
  notifyCreditPurchaseReceipt(tenantId: string, email: string, amountDollars: string, newBalanceDollars: string): void {
137
- this.queue.enqueue(tenantId, "credit-purchase-receipt", {
143
+ this.enqueue(tenantId, "credit-purchase-receipt", {
138
144
  email,
139
145
  amountDollars,
140
146
  newBalanceDollars,
@@ -156,7 +162,7 @@ export class NotificationService {
156
162
  weekEndDate: string,
157
163
  ): void {
158
164
  const unsubscribeUrl = `${this.appBaseUrl}/settings/notifications`;
159
- this.queue.enqueue(tenantId, "dividend-weekly-digest", {
165
+ this.enqueue(tenantId, "dividend-weekly-digest", {
160
166
  email,
161
167
  weeklyTotalDollars,
162
168
  weeklyTotalCents,
@@ -178,7 +184,7 @@ export class NotificationService {
178
184
  amountDollars: string,
179
185
  newBalanceDollars: string,
180
186
  ): void {
181
- this.queue.enqueue(tenantId, "crypto-payment-confirmed", {
187
+ this.enqueue(tenantId, "crypto-payment-confirmed", {
182
188
  email,
183
189
  amountDollars,
184
190
  newBalanceDollars,
@@ -190,23 +196,23 @@ export class NotificationService {
190
196
  // ---------------------------------------------------------------------------
191
197
 
192
198
  notifyAdminSuspended(tenantId: string, email: string, reason: string): void {
193
- this.queue.enqueue(tenantId, "admin-suspended", { email, reason });
199
+ this.enqueue(tenantId, "admin-suspended", { email, reason });
194
200
  }
195
201
 
196
202
  notifyAdminReactivated(tenantId: string, email: string): void {
197
- this.queue.enqueue(tenantId, "admin-reactivated", { email });
203
+ this.enqueue(tenantId, "admin-reactivated", { email });
198
204
  }
199
205
 
200
206
  notifyCreditsGranted(tenantId: string, email: string, amountDollars: string, reason: string): void {
201
- this.queue.enqueue(tenantId, "credits-granted", { email, amountDollars, reason });
207
+ this.enqueue(tenantId, "credits-granted", { email, amountDollars, reason });
202
208
  }
203
209
 
204
210
  notifyRoleChanged(tenantId: string, email: string, newRole: string): void {
205
- this.queue.enqueue(tenantId, "role-changed", { email, newRole });
211
+ this.enqueue(tenantId, "role-changed", { email, newRole });
206
212
  }
207
213
 
208
214
  notifyTeamInvite(tenantId: string, email: string, tenantName: string, inviteUrl: string): void {
209
- this.queue.enqueue(tenantId, "team-invite", { email, tenantName, inviteUrl });
215
+ this.enqueue(tenantId, "team-invite", { email, tenantName, inviteUrl });
210
216
  }
211
217
 
212
218
  // ---------------------------------------------------------------------------
@@ -214,11 +220,11 @@ export class NotificationService {
214
220
  // ---------------------------------------------------------------------------
215
221
 
216
222
  notifyAgentCreated(tenantId: string, email: string, agentName: string): void {
217
- this.queue.enqueue(tenantId, "agent-created", { email, agentName });
223
+ this.enqueue(tenantId, "agent-created", { email, agentName });
218
224
  }
219
225
 
220
226
  notifyChannelConnected(tenantId: string, email: string, channelName: string, agentName: string): void {
221
- this.queue.enqueue(tenantId, "channel-connected", { email, channelName, agentName });
227
+ this.enqueue(tenantId, "channel-connected", { email, channelName, agentName });
222
228
  }
223
229
 
224
230
  notifyChannelDisconnected(
@@ -228,11 +234,11 @@ export class NotificationService {
228
234
  agentName: string,
229
235
  reason: string,
230
236
  ): void {
231
- this.queue.enqueue(tenantId, "channel-disconnected", { email, channelName, agentName, reason });
237
+ this.enqueue(tenantId, "channel-disconnected", { email, channelName, agentName, reason });
232
238
  }
233
239
 
234
240
  notifyAgentSuspended(tenantId: string, email: string, agentName: string, reason: string): void {
235
- this.queue.enqueue(tenantId, "agent-suspended", { email, agentName, reason });
241
+ this.enqueue(tenantId, "agent-suspended", { email, agentName, reason });
236
242
  }
237
243
 
238
244
  // ---------------------------------------------------------------------------
@@ -240,7 +246,7 @@ export class NotificationService {
240
246
  // ---------------------------------------------------------------------------
241
247
 
242
248
  notifyAccountDeletionRequested(tenantId: string, email: string, deleteAfterDate: string): void {
243
- this.queue.enqueue(tenantId, "account-deletion-requested", {
249
+ this.enqueue(tenantId, "account-deletion-requested", {
244
250
  email,
245
251
  deleteAfterDate,
246
252
  cancelUrl: `${this.appBaseUrl}/settings/account`,
@@ -248,11 +254,11 @@ export class NotificationService {
248
254
  }
249
255
 
250
256
  notifyAccountDeletionCancelled(tenantId: string, email: string): void {
251
- this.queue.enqueue(tenantId, "account-deletion-cancelled", { email });
257
+ this.enqueue(tenantId, "account-deletion-cancelled", { email });
252
258
  }
253
259
 
254
260
  notifyAccountDeletionCompleted(tenantId: string, email: string): void {
255
- this.queue.enqueue(tenantId, "account-deletion-completed", { email });
261
+ this.enqueue(tenantId, "account-deletion-completed", { email });
256
262
  }
257
263
 
258
264
  // ---------------------------------------------------------------------------
@@ -266,7 +272,7 @@ export class NotificationService {
266
272
  changelogDate: string,
267
273
  changelogSummary: string,
268
274
  ): void {
269
- this.queue.enqueue(tenantId, "fleet-update-available", {
275
+ this.enqueue(tenantId, "fleet-update-available", {
270
276
  email,
271
277
  version,
272
278
  changelogDate,
@@ -276,7 +282,7 @@ export class NotificationService {
276
282
  }
277
283
 
278
284
  notifyFleetUpdateComplete(tenantId: string, email: string, version: string, succeeded: number, failed: number): void {
279
- this.queue.enqueue(tenantId, "fleet-update-complete", {
285
+ this.enqueue(tenantId, "fleet-update-complete", {
280
286
  email,
281
287
  version,
282
288
  succeeded,
@@ -291,6 +297,6 @@ export class NotificationService {
291
297
  // ---------------------------------------------------------------------------
292
298
 
293
299
  sendCustomEmail(tenantId: string, email: string, subject: string, bodyText: string): void {
294
- this.queue.enqueue(tenantId, "custom", { email, subject, bodyText });
300
+ this.enqueue(tenantId, "custom", { email, subject, bodyText });
295
301
  }
296
302
  }