forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotification.service.ts
More file actions
68 lines (60 loc) · 2.23 KB
/
Copy pathnotification.service.ts
File metadata and controls
68 lines (60 loc) · 2.23 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
import { Injectable, Logger } from '@nestjs/common';
import { CollaborationNotificationDispatcher } from './collaboration-notification-dispatcher';
export interface CollaborationInvitationNotification {
collaborationId: string;
trackTitle: string;
inviterWallet: string;
role: string;
message?: string;
}
export interface CollaborationResponseNotification {
collaborationId: string;
artistName: string;
artistWallet: string;
status: string;
responseMessage?: string;
}
export interface CollaborationRemovalNotification {
collaborationId: string;
removerWallet: string;
removalReason: string;
}
@Injectable()
export class CollaborationNotificationService {
private readonly logger = new Logger(CollaborationNotificationService.name);
constructor(private readonly dispatcher: CollaborationNotificationDispatcher) {}
async sendCollaborationInvitation(
artistWallet: string,
notification: CollaborationInvitationNotification,
): Promise<void> {
this.logger.log(
`Dispatching collaboration invitation to ${artistWallet} for track "${notification.trackTitle}"`,
);
const result = await this.dispatcher.dispatchInvitation(artistWallet, notification);
if (result.failures.length > 0) {
this.logger.warn(`Invitation delivery had failures: ${result.failures.join('; ')}`);
}
}
async sendCollaborationResponse(
inviterWallet: string,
notification: CollaborationResponseNotification,
): Promise<void> {
this.logger.log(
`Dispatching collaboration response to ${inviterWallet} — status: ${notification.status}`,
);
const result = await this.dispatcher.dispatchResponse(inviterWallet, notification);
if (result.failures.length > 0) {
this.logger.warn(`Response delivery had failures: ${result.failures.join('; ')}`);
}
}
async sendCollaborationRemoval(
recipientWallet: string,
notification: CollaborationRemovalNotification,
): Promise<void> {
this.logger.log(`Dispatching collaboration removal to ${recipientWallet}`);
const result = await this.dispatcher.dispatchRemoval(recipientWallet, notification);
if (result.failures.length > 0) {
this.logger.warn(`Removal delivery had failures: ${result.failures.join('; ')}`);
}
}
}