@lyxa.ai/core 1.3.256 → 1.3.258
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.
- package/dist/libraries/firebase/fcmService.d.ts +13 -1
- package/dist/libraries/firebase/fcmService.js +105 -13
- package/dist/libraries/firebase/fcmService.js.map +1 -1
- package/dist/libraries/socket/events/chatlist-message-send.socket.event.d.ts +12 -0
- package/dist/libraries/socket/events/chatlist-message-send.socket.event.js +1 -0
- package/dist/libraries/socket/events/chatlist-message-send.socket.event.js.map +1 -1
- package/dist/libraries/socket/events/chatroom-message-send.socket.event.d.ts +13 -0
- package/dist/libraries/socket/events/chatroom-message-send.socket.event.js +3 -0
- package/dist/libraries/socket/events/chatroom-message-send.socket.event.js.map +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { App } from 'firebase-admin/app';
|
|
2
|
+
import { AppPlatform, AuthEntityType } from '../../utilities/enum';
|
|
2
3
|
export interface FCMNotificationPayload {
|
|
3
4
|
title?: string;
|
|
4
5
|
body?: string;
|
|
@@ -6,6 +7,13 @@ export interface FCMNotificationPayload {
|
|
|
6
7
|
sound?: string;
|
|
7
8
|
invisible?: boolean;
|
|
8
9
|
}
|
|
10
|
+
export interface NotificationTokenTarget {
|
|
11
|
+
token: string;
|
|
12
|
+
entityType: AuthEntityType;
|
|
13
|
+
entityId: string;
|
|
14
|
+
platform?: AppPlatform;
|
|
15
|
+
appVersion?: string;
|
|
16
|
+
}
|
|
9
17
|
export declare const FCMServiceForUser = "fcm.service.user";
|
|
10
18
|
export declare const FCMServiceForRider = "fcm.service.rider";
|
|
11
19
|
export declare const FCMServiceForShop = "fcm.service.shop";
|
|
@@ -14,8 +22,12 @@ export declare class FCMService {
|
|
|
14
22
|
private static readonly MAX_BATCH;
|
|
15
23
|
constructor(app?: App);
|
|
16
24
|
private chunkArray;
|
|
25
|
+
private compareVersions;
|
|
26
|
+
private isNotifiableEntityType;
|
|
27
|
+
private shouldUseNewStructure;
|
|
17
28
|
private buildMessage;
|
|
18
|
-
|
|
29
|
+
private buildOldMessage;
|
|
30
|
+
sendNotification(payload: FCMNotificationPayload, targets: NotificationTokenTarget[]): Promise<{
|
|
19
31
|
successTokens: string[];
|
|
20
32
|
failedTokens: string[];
|
|
21
33
|
}>;
|
|
@@ -14,6 +14,21 @@ exports.FCMService = exports.FCMServiceForShop = exports.FCMServiceForRider = ex
|
|
|
14
14
|
const firebase_admin_1 = require("firebase-admin");
|
|
15
15
|
const __1 = require("../..");
|
|
16
16
|
const typedi_1 = require("typedi");
|
|
17
|
+
const enum_1 = require("../../utilities/enum");
|
|
18
|
+
const NotificationVersionRules = {
|
|
19
|
+
[enum_1.AuthEntityType.DELIVERY_BOY]: {
|
|
20
|
+
[enum_1.AppPlatform.IOS]: '1.0.4',
|
|
21
|
+
[enum_1.AppPlatform.ANDROID]: '1.2.1',
|
|
22
|
+
},
|
|
23
|
+
[enum_1.AuthEntityType.USER]: {
|
|
24
|
+
[enum_1.AppPlatform.IOS]: '1.0.2',
|
|
25
|
+
[enum_1.AppPlatform.ANDROID]: '1.1.3',
|
|
26
|
+
},
|
|
27
|
+
[enum_1.AuthEntityType.SELLER]: {
|
|
28
|
+
[enum_1.AppPlatform.IOS]: '1.1.0',
|
|
29
|
+
[enum_1.AppPlatform.ANDROID]: '1.0.9',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
17
32
|
exports.FCMServiceForUser = 'fcm.service.user';
|
|
18
33
|
exports.FCMServiceForRider = 'fcm.service.rider';
|
|
19
34
|
exports.FCMServiceForShop = 'fcm.service.shop';
|
|
@@ -32,6 +47,29 @@ let FCMService = class FCMService {
|
|
|
32
47
|
}
|
|
33
48
|
return chunks;
|
|
34
49
|
}
|
|
50
|
+
compareVersions(v1, v2) {
|
|
51
|
+
const a = v1.split('.').map(Number);
|
|
52
|
+
const b = v2.split('.').map(Number);
|
|
53
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
54
|
+
const diff = (a[i] || 0) - (b[i] || 0);
|
|
55
|
+
if (diff !== 0)
|
|
56
|
+
return diff;
|
|
57
|
+
}
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
isNotifiableEntityType(type) {
|
|
61
|
+
return (type === enum_1.AuthEntityType.USER || type === enum_1.AuthEntityType.SELLER || type === enum_1.AuthEntityType.DELIVERY_BOY);
|
|
62
|
+
}
|
|
63
|
+
shouldUseNewStructure(entityType, platform, version) {
|
|
64
|
+
if (!this.isNotifiableEntityType(entityType))
|
|
65
|
+
return false;
|
|
66
|
+
if (!platform || !version)
|
|
67
|
+
return false;
|
|
68
|
+
const minVersion = NotificationVersionRules?.[entityType]?.[platform];
|
|
69
|
+
if (!minVersion)
|
|
70
|
+
return false;
|
|
71
|
+
return this.compareVersions(version, minVersion) >= 0;
|
|
72
|
+
}
|
|
35
73
|
buildMessage(payload, batchTokens) {
|
|
36
74
|
const isInvisible = payload.invisible === true;
|
|
37
75
|
const channelId = payload.sound ? 'order_alert' : 'default';
|
|
@@ -62,15 +100,60 @@ let FCMService = class FCMService {
|
|
|
62
100
|
};
|
|
63
101
|
return message;
|
|
64
102
|
}
|
|
65
|
-
|
|
66
|
-
|
|
103
|
+
buildOldMessage(payload, batchTokens) {
|
|
104
|
+
const isInvisible = payload.invisible === true;
|
|
105
|
+
const message = {
|
|
106
|
+
data: payload.data || {},
|
|
107
|
+
notification: {
|
|
108
|
+
title: payload.title,
|
|
109
|
+
body: payload.body,
|
|
110
|
+
},
|
|
111
|
+
tokens: batchTokens,
|
|
112
|
+
android: { priority: 'high' },
|
|
113
|
+
apns: {
|
|
114
|
+
payload: {
|
|
115
|
+
aps: {
|
|
116
|
+
sound: payload.sound || 'default',
|
|
117
|
+
contentAvailable: true,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
if (!isInvisible) {
|
|
123
|
+
message.notification = {
|
|
124
|
+
title: payload.title,
|
|
125
|
+
body: payload.body,
|
|
126
|
+
};
|
|
127
|
+
message.android = {
|
|
128
|
+
priority: 'high',
|
|
129
|
+
notification: {
|
|
130
|
+
channelId: payload.sound ? 'android_Push_Notification_Channel_1' : 'default',
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return message;
|
|
135
|
+
}
|
|
136
|
+
async sendNotification(payload, targets) {
|
|
137
|
+
if (!targets.length) {
|
|
67
138
|
return { successTokens: [], failedTokens: [] };
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
139
|
+
}
|
|
140
|
+
const oldTokens = [];
|
|
141
|
+
const newTokens = [];
|
|
142
|
+
for (const t of targets) {
|
|
143
|
+
const useNew = this.shouldUseNewStructure(t.entityType, t.platform, t.appVersion);
|
|
144
|
+
if (useNew)
|
|
145
|
+
newTokens.push(t.token);
|
|
146
|
+
else
|
|
147
|
+
oldTokens.push(t.token);
|
|
148
|
+
}
|
|
149
|
+
const sendGroup = async (groupTokens, groupPayload, oldNotificationStructure = false) => {
|
|
150
|
+
const tokenChunks = this.chunkArray(groupTokens, FCMService_1.MAX_BATCH);
|
|
151
|
+
const success = [];
|
|
152
|
+
const failed = [];
|
|
72
153
|
const results = await Promise.all(tokenChunks.map(async (chunk) => {
|
|
73
|
-
const message =
|
|
154
|
+
const message = oldNotificationStructure
|
|
155
|
+
? this.buildOldMessage(groupPayload, chunk)
|
|
156
|
+
: this.buildMessage(groupPayload, chunk);
|
|
74
157
|
const response = await this.messaging.sendEachForMulticast(message);
|
|
75
158
|
const batchSuccess = [];
|
|
76
159
|
const batchFailed = [];
|
|
@@ -90,15 +173,24 @@ let FCMService = class FCMService {
|
|
|
90
173
|
return { batchSuccess, batchFailed };
|
|
91
174
|
}));
|
|
92
175
|
for (const r of results) {
|
|
93
|
-
|
|
94
|
-
|
|
176
|
+
success.push(...r.batchSuccess);
|
|
177
|
+
failed.push(...r.batchFailed);
|
|
95
178
|
}
|
|
96
|
-
return {
|
|
179
|
+
return { success, failed };
|
|
180
|
+
};
|
|
181
|
+
let successTokens = [];
|
|
182
|
+
let failedTokens = [];
|
|
183
|
+
if (oldTokens.length) {
|
|
184
|
+
const r = await sendGroup(oldTokens, payload, true);
|
|
185
|
+
successTokens.push(...r.success);
|
|
186
|
+
failedTokens.push(...r.failed);
|
|
97
187
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
188
|
+
if (newTokens.length) {
|
|
189
|
+
const r = await sendGroup(newTokens, payload, false);
|
|
190
|
+
successTokens.push(...r.success);
|
|
191
|
+
failedTokens.push(...r.failed);
|
|
101
192
|
}
|
|
193
|
+
return { successTokens, failedTokens };
|
|
102
194
|
}
|
|
103
195
|
};
|
|
104
196
|
exports.FCMService = FCMService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fcmService.js","sourceRoot":"/","sources":["libraries/firebase/fcmService.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mDAA2C;AAC3C,6BAAqC;AACrC,mCAAiC;AAWpB,QAAA,iBAAiB,GAAG,kBAAkB,CAAC;AACvC,QAAA,kBAAkB,GAAG,mBAAmB,CAAC;AACzC,QAAA,iBAAiB,GAAG,kBAAkB,CAAC;AAG7C,IAAM,UAAU,GAAhB,MAAM,UAAU;;IACd,SAAS,CAAuB;IAChC,MAAM,CAAU,SAAS,GAAG,GAAG,CAAC;IAExC,YAAY,GAAS;QACpB,MAAM,WAAW,GAAG,GAAG,IAAI,IAAA,gBAAY,GAAE,CAAC,kBAAkB,EAAE,CAAC,QAAQ,CAAC;QACxE,IAAI,CAAC,SAAS,GAAG,IAAA,0BAAS,EAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IAKO,UAAU,CAAI,GAAQ,EAAE,IAAY;QAC3C,MAAM,MAAM,GAAU,EAAE,CAAC;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,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AC,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC;gBACtC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC;YACrC,CAAC;YAED,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;QACxC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;YAClD,MAAM,GAAG,CAAC;QACX,CAAC;IACF,CAAC;;AAlHW,gCAAU;qBAAV,UAAU;IADtB,IAAA,gBAAO,GAAE;;GACG,UAAU,CAmHtB","sourcesContent":["import { messaging } from 'firebase-admin';\nimport { getLibraries } from '../..';\nimport { Service } from 'typedi';\nimport { App } from 'firebase-admin/app';\n\nexport interface FCMNotificationPayload {\n\ttitle?: string;\n\tbody?: string;\n\tdata?: Record<string, string>;\n\tsound?: string;\n\tinvisible?: boolean;\n}\n\nexport const FCMServiceForUser = 'fcm.service.user';\nexport const FCMServiceForRider = 'fcm.service.rider';\nexport const FCMServiceForShop = 'fcm.service.shop';\n\n@Service()\nexport class FCMService {\n\tprivate messaging!: messaging.Messaging;\n\tprivate static readonly MAX_BATCH = 500;\n\n\tconstructor(app?: App) {\n\t\tconst firebaseApp = app ?? getLibraries().getFirebaseService().superApp;\n\t\tthis.messaging = messaging(firebaseApp);\n\t}\n\n\t/**\n\t * Split array into chunks of fixed size\n\t */\n\tprivate chunkArray<T>(arr: T[], size: number): T[][] {\n\t\tconst chunks: T[][] = [];\n\t\tfor (let i = 0; i < arr.length; i += size) {\n\t\t\tchunks.push(arr.slice(i, i + size));\n\t\t}\n\t\treturn chunks;\n\t}\n\n\t/**\n\t * Build multicast message safely\n\t */\n\tprivate buildMessage(payload: FCMNotificationPayload, batchTokens: string[]): messaging.MulticastMessage {\n\t\tconst isInvisible = payload.invisible === true;\n\t\tconst channelId = payload.sound ? 'order_alert' : 'default';\n\n\t\tconst message: messaging.MulticastMessage = {\n\t\t\tdata: { ...payload.data, channelId: isInvisible ? 'silent' : channelId },\n\t\t\tnotification: {\n\t\t\t\ttitle: payload.title,\n\t\t\t\tbody: payload.body,\n\t\t\t},\n\t\t\ttokens: batchTokens,\n\t\t\tandroid: {\n\t\t\t\tpriority: 'high',\n\t\t\t\tnotification: {\n\t\t\t\t\tchannelId: 'silent',\n\t\t\t\t},\n\t\t\t},\n\t\t\tapns: {\n\t\t\t\tpayload: {\n\t\t\t\t\taps: {\n\t\t\t\t\t\tsound: payload.sound || 'default',\n\t\t\t\t\t\tcontentAvailable: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\theaders: {\n\t\t\t\t\t'apns-push-type': 'background',\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\treturn message;\n\t}\n\n\t/**\n\t * Sends a push notification (visible or invisible) to multiple device tokens\n\t * @param payload - Notification title, body, and optional data\n\t * @param tokens - FCM device tokens\n\t * @returns Object containing success and invalid tokens\n\t */\n\tasync sendNotification(\n\t\tpayload: FCMNotificationPayload,\n\t\ttokens: string[]\n\t): Promise<{ successTokens: string[]; failedTokens: string[] }> {\n\t\tif (!tokens.length) return { successTokens: [], failedTokens: [] };\n\n\t\tconst tokenChunks = this.chunkArray(tokens, FCMService.MAX_BATCH);\n\n\t\tlet successTokens: string[] = [];\n\t\tlet failedTokens: string[] = [];\n\n\t\ttry {\n\t\t\t// Parallel batch sending (safe & fast)\n\t\t\tconst results = await Promise.all(\n\t\t\t\ttokenChunks.map(async chunk => {\n\t\t\t\t\tconst message = this.buildMessage(payload, chunk);\n\t\t\t\t\tconst response = await this.messaging.sendEachForMulticast(message);\n\n\t\t\t\t\tconst batchSuccess: string[] = [];\n\t\t\t\t\tconst batchFailed: string[] = [];\n\n\t\t\t\t\tresponse.responses.forEach((resp, idx) => {\n\t\t\t\t\t\tif (resp.success) {\n\t\t\t\t\t\t\tbatchSuccess.push(chunk[idx]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst errorCode = resp.error?.code;\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\terrorCode === 'messaging/invalid-argument' ||\n\t\t\t\t\t\t\t\terrorCode === 'messaging/registration-token-not-registered'\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tbatchFailed.push(chunk[idx]);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconsole.warn(`FCM Error for token ${chunk[idx]}:`, resp.error?.message);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\treturn { batchSuccess, batchFailed };\n\t\t\t\t})\n\t\t\t);\n\n\t\t\tfor (const r of results) {\n\t\t\t\tsuccessTokens.push(...r.batchSuccess);\n\t\t\t\tfailedTokens.push(...r.batchFailed);\n\t\t\t}\n\n\t\t\treturn { successTokens, failedTokens };\n\t\t} catch (err) {\n\t\t\tconsole.error('FCM sendNotification error:', err);\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fcmService.js","sourceRoot":"/","sources":["libraries/firebase/fcmService.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mDAA2C;AAC3C,6BAAqC;AACrC,mCAAiC;AAEjC,+CAAmE;AAoBnE,MAAM,wBAAwB,GAAuE;IACpG,CAAC,qBAAc,CAAC,YAAY,CAAC,EAAE;QAC9B,CAAC,kBAAW,CAAC,GAAG,CAAC,EAAE,OAAO;QAC1B,CAAC,kBAAW,CAAC,OAAO,CAAC,EAAE,OAAO;KAC9B;IAED,CAAC,qBAAc,CAAC,IAAI,CAAC,EAAE;QACtB,CAAC,kBAAW,CAAC,GAAG,CAAC,EAAE,OAAO;QAC1B,CAAC,kBAAW,CAAC,OAAO,CAAC,EAAE,OAAO;KAC9B;IAED,CAAC,qBAAc,CAAC,MAAM,CAAC,EAAE;QACxB,CAAC,kBAAW,CAAC,GAAG,CAAC,EAAE,OAAO;QAC1B,CAAC,kBAAW,CAAC,OAAO,CAAC,EAAE,OAAO;KAC9B;CACD,CAA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CAAC,OAAO,CAAC,CAAC;YACjC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;QAChC,CAAC;QAGD,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,MAAM,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;YAErD,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;YACjC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;IACxC,CAAC;;AApOW,gCAAU;qBAAV,UAAU;IADtB,IAAA,gBAAO,GAAE;;GACG,UAAU,CAqOtB","sourcesContent":["import { messaging } from 'firebase-admin';\nimport { getLibraries } from '../..';\nimport { Service } from 'typedi';\nimport { App } from 'firebase-admin/app';\nimport { AppPlatform, AuthEntityType } from '../../utilities/enum';\n\nexport interface FCMNotificationPayload {\n\ttitle?: string;\n\tbody?: string;\n\tdata?: Record<string, string>;\n\tsound?: string;\n\tinvisible?: boolean;\n}\n\nexport interface NotificationTokenTarget {\n\ttoken: string;\n\tentityType: AuthEntityType;\n\tentityId: string;\n\tplatform?: AppPlatform;\n\tappVersion?: string;\n}\n\ntype NotifiableEntityType = AuthEntityType.USER | AuthEntityType.SELLER | AuthEntityType.DELIVERY_BOY;\n\nconst NotificationVersionRules: Record<NotifiableEntityType, Partial<Record<AppPlatform, string>>> = {\n\t[AuthEntityType.DELIVERY_BOY]: {\n\t\t[AppPlatform.IOS]: '1.0.4',\n\t\t[AppPlatform.ANDROID]: '1.2.1',\n\t},\n\n\t[AuthEntityType.USER]: {\n\t\t[AppPlatform.IOS]: '1.0.2',\n\t\t[AppPlatform.ANDROID]: '1.1.3',\n\t},\n\n\t[AuthEntityType.SELLER]: {\n\t\t[AppPlatform.IOS]: '1.1.0',\n\t\t[AppPlatform.ANDROID]: '1.0.9',\n\t},\n};\n\nexport const FCMServiceForUser = 'fcm.service.user';\nexport const FCMServiceForRider = 'fcm.service.rider';\nexport const FCMServiceForShop = 'fcm.service.shop';\n\n@Service()\nexport class FCMService {\n\tprivate messaging!: messaging.Messaging;\n\tprivate static readonly MAX_BATCH = 500;\n\n\tconstructor(app?: App) {\n\t\tconst firebaseApp = app ?? getLibraries().getFirebaseService().superApp;\n\t\tthis.messaging = messaging(firebaseApp);\n\t}\n\n\t/**\n\t * Split array into chunks of fixed size\n\t */\n\tprivate chunkArray<T>(arr: T[], size: number): T[][] {\n\t\tconst chunks: T[][] = [];\n\t\tfor (let i = 0; i < arr.length; i += size) {\n\t\t\tchunks.push(arr.slice(i, i + size));\n\t\t}\n\t\treturn chunks;\n\t}\n\n\tprivate compareVersions(v1: string, v2: string): number {\n\t\tconst a = v1.split('.').map(Number);\n\t\tconst b = v2.split('.').map(Number);\n\n\t\tfor (let i = 0; i < Math.max(a.length, b.length); i++) {\n\t\t\tconst diff = (a[i] || 0) - (b[i] || 0);\n\t\t\tif (diff !== 0) return diff;\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tprivate isNotifiableEntityType(type: AuthEntityType): type is NotifiableEntityType {\n\t\treturn (\n\t\t\ttype === AuthEntityType.USER || type === AuthEntityType.SELLER || type === AuthEntityType.DELIVERY_BOY\n\t\t);\n\t}\n\n\tprivate shouldUseNewStructure(\n\t\tentityType: AuthEntityType,\n\t\tplatform?: AppPlatform,\n\t\tversion?: string\n\t): boolean {\n\t\tif (!this.isNotifiableEntityType(entityType)) return false;\n\n\t\tif (!platform || !version) return false;\n\n\t\tconst minVersion = NotificationVersionRules?.[entityType]?.[platform];\n\n\t\tif (!minVersion) return false;\n\n\t\treturn this.compareVersions(version, minVersion) >= 0;\n\t}\n\n\t/**\n\t * Build multicast message safely\n\t */\n\tprivate buildMessage(payload: FCMNotificationPayload, batchTokens: string[]): messaging.MulticastMessage {\n\t\tconst isInvisible = payload.invisible === true;\n\t\tconst channelId = payload.sound ? 'order_alert' : 'default';\n\n\t\tconst message: messaging.MulticastMessage = {\n\t\t\tdata: { ...payload.data, channelId: isInvisible ? 'silent' : channelId },\n\t\t\tnotification: {\n\t\t\t\ttitle: payload.title,\n\t\t\t\tbody: payload.body,\n\t\t\t},\n\t\t\ttokens: batchTokens,\n\t\t\tandroid: {\n\t\t\t\tpriority: 'high',\n\t\t\t\tnotification: {\n\t\t\t\t\tchannelId: 'silent',\n\t\t\t\t},\n\t\t\t},\n\t\t\tapns: {\n\t\t\t\tpayload: {\n\t\t\t\t\taps: {\n\t\t\t\t\t\tsound: payload.sound || 'default',\n\t\t\t\t\t\tcontentAvailable: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\theaders: {\n\t\t\t\t\t'apns-push-type': 'background',\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\treturn message;\n\t}\n\n\t/**\n\t * Build multicast message safely for old apps\n\t */\n\tprivate buildOldMessage(\n\t\tpayload: FCMNotificationPayload,\n\t\tbatchTokens: string[]\n\t): messaging.MulticastMessage {\n\t\tconst isInvisible = payload.invisible === true;\n\n\t\tconst message: messaging.MulticastMessage = {\n\t\t\tdata: payload.data || {},\n\t\t\tnotification: {\n\t\t\t\ttitle: payload.title,\n\t\t\t\tbody: payload.body,\n\t\t\t},\n\t\t\ttokens: batchTokens,\n\t\t\tandroid: { priority: 'high' },\n\t\t\tapns: {\n\t\t\t\tpayload: {\n\t\t\t\t\taps: {\n\t\t\t\t\t\tsound: payload.sound || 'default',\n\t\t\t\t\t\tcontentAvailable: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tif (!isInvisible) {\n\t\t\tmessage.notification = {\n\t\t\t\ttitle: payload.title,\n\t\t\t\tbody: payload.body,\n\t\t\t};\n\n\t\t\tmessage.android = {\n\t\t\t\tpriority: 'high',\n\t\t\t\tnotification: {\n\t\t\t\t\tchannelId: payload.sound ? 'android_Push_Notification_Channel_1' : 'default',\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn message;\n\t}\n\n\t/**\n\t * Sends a push notification (visible or invisible) to multiple device tokens\n\t * @param payload - Notification title, body, and optional data\n\t * @param tokens - FCM device tokens\n\t * @returns Object containing success and invalid tokens\n\t */\n\tasync sendNotification(\n\t\tpayload: FCMNotificationPayload,\n\t\ttargets: NotificationTokenTarget[]\n\t): Promise<{ successTokens: string[]; failedTokens: string[] }> {\n\t\tif (!targets.length) {\n\t\t\treturn { successTokens: [], failedTokens: [] };\n\t\t}\n\n\t\tconst oldTokens: string[] = [];\n\t\tconst newTokens: string[] = [];\n\n\t\tfor (const t of targets) {\n\t\t\tconst useNew = this.shouldUseNewStructure(t.entityType, t.platform, t.appVersion);\n\n\t\t\tif (useNew) newTokens.push(t.token);\n\t\t\telse oldTokens.push(t.token);\n\t\t}\n\n\t\tconst sendGroup = async (\n\t\t\tgroupTokens: string[],\n\t\t\tgroupPayload: FCMNotificationPayload,\n\t\t\toldNotificationStructure: boolean = false\n\t\t) => {\n\t\t\tconst tokenChunks = this.chunkArray(groupTokens, FCMService.MAX_BATCH);\n\n\t\t\tconst success: string[] = [];\n\t\t\tconst failed: string[] = [];\n\n\t\t\tconst results = await Promise.all(\n\t\t\t\ttokenChunks.map(async chunk => {\n\t\t\t\t\tconst message = oldNotificationStructure\n\t\t\t\t\t\t? this.buildOldMessage(groupPayload, chunk)\n\t\t\t\t\t\t: this.buildMessage(groupPayload, chunk);\n\n\t\t\t\t\tconst response = await this.messaging.sendEachForMulticast(message);\n\n\t\t\t\t\tconst batchSuccess: string[] = [];\n\t\t\t\t\tconst batchFailed: string[] = [];\n\n\t\t\t\t\tresponse.responses.forEach((resp, idx) => {\n\t\t\t\t\t\tif (resp.success) {\n\t\t\t\t\t\t\tbatchSuccess.push(chunk[idx]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst errorCode = resp.error?.code;\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\terrorCode === 'messaging/invalid-argument' ||\n\t\t\t\t\t\t\t\terrorCode === 'messaging/registration-token-not-registered'\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tbatchFailed.push(chunk[idx]);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconsole.warn(`FCM Error for token ${chunk[idx]}:`, resp.error?.message);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\treturn { batchSuccess, batchFailed };\n\t\t\t\t})\n\t\t\t);\n\n\t\t\tfor (const r of results) {\n\t\t\t\tsuccess.push(...r.batchSuccess);\n\t\t\t\tfailed.push(...r.batchFailed);\n\t\t\t}\n\n\t\t\treturn { success, failed };\n\t\t};\n\n\t\tlet successTokens: string[] = [];\n\t\tlet failedTokens: string[] = [];\n\n\t\t// send old payload\n\t\tif (oldTokens.length) {\n\t\t\tconst r = await sendGroup(oldTokens, payload, true);\n\n\t\t\tsuccessTokens.push(...r.success);\n\t\t\tfailedTokens.push(...r.failed);\n\t\t}\n\n\t\t// send new payload\n\t\tif (newTokens.length) {\n\t\t\tconst r = await sendGroup(newTokens, payload, false);\n\n\t\t\tsuccessTokens.push(...r.success);\n\t\t\tfailedTokens.push(...r.failed);\n\t\t}\n\n\t\treturn { successTokens, failedTokens };\n\t}\n}\n"]}
|
|
@@ -5,6 +5,7 @@ import { NotificationSettings } from '../PushNotificationEvent';
|
|
|
5
5
|
export declare const ChatlistMessageSendSocketInputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
6
6
|
export declare const ChatlistMessageSendSocketOutputSchema: z.ZodObject<{
|
|
7
7
|
chatroomId: z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>;
|
|
8
|
+
orderId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
|
|
8
9
|
lastMessage: z.ZodOptional<z.ZodObject<{
|
|
9
10
|
content: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
10
11
|
createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
|
|
@@ -23,6 +24,7 @@ export declare const ChatlistMessageSendSocketOutputSchema: z.ZodObject<{
|
|
|
23
24
|
content: string;
|
|
24
25
|
createdAt: Date;
|
|
25
26
|
} | undefined;
|
|
27
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
26
28
|
}, {
|
|
27
29
|
unreadCount: number;
|
|
28
30
|
chatroomId: import("mongoose").Types.ObjectId;
|
|
@@ -30,9 +32,11 @@ export declare const ChatlistMessageSendSocketOutputSchema: z.ZodObject<{
|
|
|
30
32
|
content: string;
|
|
31
33
|
createdAt: Date;
|
|
32
34
|
} | undefined;
|
|
35
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
33
36
|
}>;
|
|
34
37
|
export declare const ChatlistMessageSendPushOutputSchema: z.ZodObject<{
|
|
35
38
|
chatroomId: z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>;
|
|
39
|
+
orderId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
|
|
36
40
|
lastMessage: z.ZodOptional<z.ZodObject<{
|
|
37
41
|
content: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
38
42
|
createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
|
|
@@ -51,6 +55,7 @@ export declare const ChatlistMessageSendPushOutputSchema: z.ZodObject<{
|
|
|
51
55
|
content: string;
|
|
52
56
|
createdAt: Date;
|
|
53
57
|
} | undefined;
|
|
58
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
54
59
|
}, {
|
|
55
60
|
unreadCount: number;
|
|
56
61
|
chatroomId: import("mongoose").Types.ObjectId;
|
|
@@ -58,6 +63,7 @@ export declare const ChatlistMessageSendPushOutputSchema: z.ZodObject<{
|
|
|
58
63
|
content: string;
|
|
59
64
|
createdAt: Date;
|
|
60
65
|
} | undefined;
|
|
66
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
61
67
|
}>;
|
|
62
68
|
export type ChatlistMessageSendPushOutputDTO = DTO<typeof ChatlistMessageSendPushOutputSchema>;
|
|
63
69
|
export type ChatlistMessageSendSocketOutputDTO = DTO<typeof ChatlistMessageSendSocketOutputSchema>;
|
|
@@ -67,6 +73,7 @@ export declare class ChatlistMessageSendSocketEvent extends BaseSocketEvent<type
|
|
|
67
73
|
input: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
68
74
|
output: z.ZodObject<{
|
|
69
75
|
chatroomId: z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>;
|
|
76
|
+
orderId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
|
|
70
77
|
lastMessage: z.ZodOptional<z.ZodObject<{
|
|
71
78
|
content: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
72
79
|
createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
|
|
@@ -85,6 +92,7 @@ export declare class ChatlistMessageSendSocketEvent extends BaseSocketEvent<type
|
|
|
85
92
|
content: string;
|
|
86
93
|
createdAt: Date;
|
|
87
94
|
} | undefined;
|
|
95
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
88
96
|
}, {
|
|
89
97
|
unreadCount: number;
|
|
90
98
|
chatroomId: import("mongoose").Types.ObjectId;
|
|
@@ -92,9 +100,11 @@ export declare class ChatlistMessageSendSocketEvent extends BaseSocketEvent<type
|
|
|
92
100
|
content: string;
|
|
93
101
|
createdAt: Date;
|
|
94
102
|
} | undefined;
|
|
103
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
95
104
|
}>;
|
|
96
105
|
pushNotificationOutput: z.ZodObject<{
|
|
97
106
|
chatroomId: z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>;
|
|
107
|
+
orderId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
|
|
98
108
|
lastMessage: z.ZodOptional<z.ZodObject<{
|
|
99
109
|
content: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
100
110
|
createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
|
|
@@ -113,6 +123,7 @@ export declare class ChatlistMessageSendSocketEvent extends BaseSocketEvent<type
|
|
|
113
123
|
content: string;
|
|
114
124
|
createdAt: Date;
|
|
115
125
|
} | undefined;
|
|
126
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
116
127
|
}, {
|
|
117
128
|
unreadCount: number;
|
|
118
129
|
chatroomId: import("mongoose").Types.ObjectId;
|
|
@@ -120,6 +131,7 @@ export declare class ChatlistMessageSendSocketEvent extends BaseSocketEvent<type
|
|
|
120
131
|
content: string;
|
|
121
132
|
createdAt: Date;
|
|
122
133
|
} | undefined;
|
|
134
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
123
135
|
}>;
|
|
124
136
|
};
|
|
125
137
|
get notificationSettings(): NotificationSettings | undefined;
|
|
@@ -11,6 +11,7 @@ const BaseSocketEvent_1 = require("../BaseSocketEvent");
|
|
|
11
11
|
exports.ChatlistMessageSendSocketInputSchema = zod_1.default.object({});
|
|
12
12
|
exports.ChatlistMessageSendSocketOutputSchema = zod_1.default.object({
|
|
13
13
|
chatroomId: validation_1.ZodValidation.coerce.objectId(),
|
|
14
|
+
orderId: validation_1.ZodValidation.coerce.objectId().optional(),
|
|
14
15
|
lastMessage: zod_1.default
|
|
15
16
|
.object({
|
|
16
17
|
content: validation_1.ZodValidation.string(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatlist-message-send.socket.event.js","sourceRoot":"/","sources":["libraries/socket/events/chatlist-message-send.socket.event.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAoB;AACpB,kDAAqE;AACrE,8DAAmE;AACnE,wDAAqD;AAIxC,QAAA,oCAAoC,GAAG,aAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACpD,QAAA,qCAAqC,GAAG,aAAC,CAAC,MAAM,CAAC;IAC7D,UAAU,EAAE,0BAAa,CAAC,MAAM,CAAC,QAAQ,EAAE;IAC3C,WAAW,EAAE,aAAC;SACZ,MAAM,CAAC;QACP,OAAO,EAAE,0BAAa,CAAC,MAAM,EAAE;QAC/B,SAAS,EAAE,0BAAa,CAAC,MAAM,CAAC,IAAI,EAAE;KACtC,CAAC;SACD,QAAQ,EAAE;IACZ,WAAW,EAAE,0BAAa,CAAC,MAAM,EAAE;CACnC,CAAC,CAAC;AAEU,QAAA,mCAAmC,GAAG,6CAAqC,CAAC;AAMzF,MAAa,8BAA+B,SAAQ,iCAInD;IACA,MAAM,CAAU,OAAO,GAAG;QACzB,KAAK,EAAE,4CAAoC;QAC3C,MAAM,EAAE,6CAAqC;QAC7C,sBAAsB,EAAE,2CAAmC;KAC3D,CAAC;IAEF,IAAW,oBAAoB;QAC9B,OAAO;YACN,kBAAkB,EAAE,IAAI;YACxB,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,gBAAS,CAAC,iBAAiB;SACtC,CAAC;IACH,CAAC;IAED,YAAY,OAA2C;QACtD,KAAK,CAAC,sBAAe,CAAC,yBAAyB,EAAE,8BAA8B,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5G,CAAC;IAES,aAAa;QACtB,OAAO,SAAS,CAAC;IAClB,CAAC;;AAzBF,wEA0BC","sourcesContent":["import z from 'zod';\nimport { ClickType, SocketEventType } from '../../../utilities/enum';\nimport { DTO, ZodValidation } from '../../../utilities/validation';\nimport { BaseSocketEvent } from '../BaseSocketEvent';\n\nimport { NotificationSettings } from '../PushNotificationEvent';\n\nexport const ChatlistMessageSendSocketInputSchema = z.object({});\nexport const ChatlistMessageSendSocketOutputSchema = z.object({\n\tchatroomId: ZodValidation.coerce.objectId(),\n\tlastMessage: z\n\t\t.object({\n\t\t\tcontent: ZodValidation.string(),\n\t\t\tcreatedAt: ZodValidation.coerce.date(),\n\t\t})\n\t\t.optional(),\n\tunreadCount: ZodValidation.number(),\n});\n\nexport const ChatlistMessageSendPushOutputSchema = ChatlistMessageSendSocketOutputSchema;\n\nexport type ChatlistMessageSendPushOutputDTO = DTO<typeof ChatlistMessageSendPushOutputSchema>;\nexport type ChatlistMessageSendSocketOutputDTO = DTO<typeof ChatlistMessageSendSocketOutputSchema>;\nexport type ChatlistMessageSendSocketInputDTO = DTO<typeof ChatlistMessageSendSocketInputSchema>;\n\nexport class ChatlistMessageSendSocketEvent extends BaseSocketEvent<\n\ttypeof ChatlistMessageSendSocketInputSchema,\n\ttypeof ChatlistMessageSendSocketOutputSchema,\n\ttypeof ChatlistMessageSendPushOutputSchema\n> {\n\tstatic readonly schemas = {\n\t\tinput: ChatlistMessageSendSocketInputSchema,\n\t\toutput: ChatlistMessageSendSocketOutputSchema,\n\t\tpushNotificationOutput: ChatlistMessageSendPushOutputSchema,\n\t};\n\n\tpublic get notificationSettings(): NotificationSettings | undefined {\n\t\treturn {\n\t\t\tisPushNotification: true,\n\t\t\tisClickable: true,\n\t\t\tclickType: ClickType.CLICKABLE_MESSAGE,\n\t\t};\n\t}\n\n\tconstructor(payload: ChatlistMessageSendSocketOutputDTO) {\n\t\tsuper(SocketEventType.CHATLIST_MESSAGE_RECEIVED, ChatlistMessageSendSocketEvent.schemas, payload, payload);\n\t}\n\n\tprotected getIdentifier(): string {\n\t\treturn 'default';\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chatlist-message-send.socket.event.js","sourceRoot":"/","sources":["libraries/socket/events/chatlist-message-send.socket.event.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAoB;AACpB,kDAAqE;AACrE,8DAAmE;AACnE,wDAAqD;AAIxC,QAAA,oCAAoC,GAAG,aAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACpD,QAAA,qCAAqC,GAAG,aAAC,CAAC,MAAM,CAAC;IAC7D,UAAU,EAAE,0BAAa,CAAC,MAAM,CAAC,QAAQ,EAAE;IAC3C,OAAO,EAAE,0BAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACnD,WAAW,EAAE,aAAC;SACZ,MAAM,CAAC;QACP,OAAO,EAAE,0BAAa,CAAC,MAAM,EAAE;QAC/B,SAAS,EAAE,0BAAa,CAAC,MAAM,CAAC,IAAI,EAAE;KACtC,CAAC;SACD,QAAQ,EAAE;IACZ,WAAW,EAAE,0BAAa,CAAC,MAAM,EAAE;CACnC,CAAC,CAAC;AAEU,QAAA,mCAAmC,GAAG,6CAAqC,CAAC;AAMzF,MAAa,8BAA+B,SAAQ,iCAInD;IACA,MAAM,CAAU,OAAO,GAAG;QACzB,KAAK,EAAE,4CAAoC;QAC3C,MAAM,EAAE,6CAAqC;QAC7C,sBAAsB,EAAE,2CAAmC;KAC3D,CAAC;IAEF,IAAW,oBAAoB;QAC9B,OAAO;YACN,kBAAkB,EAAE,IAAI;YACxB,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,gBAAS,CAAC,iBAAiB;SACtC,CAAC;IACH,CAAC;IAED,YAAY,OAA2C;QACtD,KAAK,CAAC,sBAAe,CAAC,yBAAyB,EAAE,8BAA8B,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5G,CAAC;IAES,aAAa;QACtB,OAAO,SAAS,CAAC;IAClB,CAAC;;AAzBF,wEA0BC","sourcesContent":["import z from 'zod';\nimport { ClickType, SocketEventType } from '../../../utilities/enum';\nimport { DTO, ZodValidation } from '../../../utilities/validation';\nimport { BaseSocketEvent } from '../BaseSocketEvent';\n\nimport { NotificationSettings } from '../PushNotificationEvent';\n\nexport const ChatlistMessageSendSocketInputSchema = z.object({});\nexport const ChatlistMessageSendSocketOutputSchema = z.object({\n\tchatroomId: ZodValidation.coerce.objectId(),\n\torderId: ZodValidation.coerce.objectId().optional(),\n\tlastMessage: z\n\t\t.object({\n\t\t\tcontent: ZodValidation.string(),\n\t\t\tcreatedAt: ZodValidation.coerce.date(),\n\t\t})\n\t\t.optional(),\n\tunreadCount: ZodValidation.number(),\n});\n\nexport const ChatlistMessageSendPushOutputSchema = ChatlistMessageSendSocketOutputSchema;\n\nexport type ChatlistMessageSendPushOutputDTO = DTO<typeof ChatlistMessageSendPushOutputSchema>;\nexport type ChatlistMessageSendSocketOutputDTO = DTO<typeof ChatlistMessageSendSocketOutputSchema>;\nexport type ChatlistMessageSendSocketInputDTO = DTO<typeof ChatlistMessageSendSocketInputSchema>;\n\nexport class ChatlistMessageSendSocketEvent extends BaseSocketEvent<\n\ttypeof ChatlistMessageSendSocketInputSchema,\n\ttypeof ChatlistMessageSendSocketOutputSchema,\n\ttypeof ChatlistMessageSendPushOutputSchema\n> {\n\tstatic readonly schemas = {\n\t\tinput: ChatlistMessageSendSocketInputSchema,\n\t\toutput: ChatlistMessageSendSocketOutputSchema,\n\t\tpushNotificationOutput: ChatlistMessageSendPushOutputSchema,\n\t};\n\n\tpublic get notificationSettings(): NotificationSettings | undefined {\n\t\treturn {\n\t\t\tisPushNotification: true,\n\t\t\tisClickable: true,\n\t\t\tclickType: ClickType.CLICKABLE_MESSAGE,\n\t\t};\n\t}\n\n\tconstructor(payload: ChatlistMessageSendSocketOutputDTO) {\n\t\tsuper(SocketEventType.CHATLIST_MESSAGE_RECEIVED, ChatlistMessageSendSocketEvent.schemas, payload, payload);\n\t}\n\n\tprotected getIdentifier(): string {\n\t\treturn 'default';\n\t}\n}\n"]}
|
|
@@ -59,6 +59,7 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
|
|
|
59
59
|
longitude?: number | undefined;
|
|
60
60
|
}>>;
|
|
61
61
|
chatroomId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
|
|
62
|
+
orderId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
|
|
62
63
|
createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
|
|
63
64
|
}, "strip", z.ZodTypeAny, {
|
|
64
65
|
media: {
|
|
@@ -83,6 +84,7 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
|
|
|
83
84
|
longitude?: number | undefined;
|
|
84
85
|
} | undefined;
|
|
85
86
|
content?: string | undefined;
|
|
87
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
86
88
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
87
89
|
}, {
|
|
88
90
|
media: {
|
|
@@ -107,19 +109,23 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
|
|
|
107
109
|
longitude?: number | undefined;
|
|
108
110
|
} | undefined;
|
|
109
111
|
content?: string | undefined;
|
|
112
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
110
113
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
111
114
|
}>;
|
|
112
115
|
export declare const ChatroomMessageSendPushOutputSchema: z.ZodObject<{
|
|
113
116
|
lastMessage: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
114
117
|
chatroomId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
|
|
118
|
+
orderId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
|
|
115
119
|
type: z.ZodNativeEnum<typeof ChatroomType>;
|
|
116
120
|
}, "strip", z.ZodTypeAny, {
|
|
117
121
|
type: ChatroomType;
|
|
118
122
|
lastMessage?: string | undefined;
|
|
123
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
119
124
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
120
125
|
}, {
|
|
121
126
|
type: ChatroomType;
|
|
122
127
|
lastMessage?: string | undefined;
|
|
128
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
123
129
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
124
130
|
}>;
|
|
125
131
|
export type ChatlistMessageSendPushOutputDTO = DTO<typeof ChatroomMessageSendPushOutputSchema>;
|
|
@@ -183,6 +189,7 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
|
|
|
183
189
|
longitude?: number | undefined;
|
|
184
190
|
}>>;
|
|
185
191
|
chatroomId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
|
|
192
|
+
orderId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
|
|
186
193
|
createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
|
|
187
194
|
}, "strip", z.ZodTypeAny, {
|
|
188
195
|
media: {
|
|
@@ -207,6 +214,7 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
|
|
|
207
214
|
longitude?: number | undefined;
|
|
208
215
|
} | undefined;
|
|
209
216
|
content?: string | undefined;
|
|
217
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
210
218
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
211
219
|
}, {
|
|
212
220
|
media: {
|
|
@@ -231,19 +239,23 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
|
|
|
231
239
|
longitude?: number | undefined;
|
|
232
240
|
} | undefined;
|
|
233
241
|
content?: string | undefined;
|
|
242
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
234
243
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
235
244
|
}>;
|
|
236
245
|
pushNotificationOutput: z.ZodObject<{
|
|
237
246
|
lastMessage: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
238
247
|
chatroomId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
|
|
248
|
+
orderId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
|
|
239
249
|
type: z.ZodNativeEnum<typeof ChatroomType>;
|
|
240
250
|
}, "strip", z.ZodTypeAny, {
|
|
241
251
|
type: ChatroomType;
|
|
242
252
|
lastMessage?: string | undefined;
|
|
253
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
243
254
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
244
255
|
}, {
|
|
245
256
|
type: ChatroomType;
|
|
246
257
|
lastMessage?: string | undefined;
|
|
258
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
247
259
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
248
260
|
}>;
|
|
249
261
|
};
|
|
@@ -254,6 +266,7 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
|
|
|
254
266
|
getPushNotificationPayload(): {
|
|
255
267
|
type: ChatroomType;
|
|
256
268
|
lastMessage?: string | undefined;
|
|
269
|
+
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
257
270
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
258
271
|
} | undefined;
|
|
259
272
|
protected getIdentifier(): string;
|
|
@@ -37,11 +37,13 @@ exports.ChatroomMessageSendOutputSchema = zod_1.default.object({
|
|
|
37
37
|
})
|
|
38
38
|
.optional(),
|
|
39
39
|
chatroomId: validation_1.ZodValidation.coerce.objectId('chatroomId').optional(),
|
|
40
|
+
orderId: validation_1.ZodValidation.coerce.objectId('orderId').optional(),
|
|
40
41
|
createdAt: validation_1.ZodValidation.coerce.date(),
|
|
41
42
|
});
|
|
42
43
|
exports.ChatroomMessageSendPushOutputSchema = zod_1.default.object({
|
|
43
44
|
lastMessage: validation_1.ZodValidation.string('lastMessage').optional(),
|
|
44
45
|
chatroomId: validation_1.ZodValidation.coerce.objectId('chatroomId').optional(),
|
|
46
|
+
orderId: validation_1.ZodValidation.coerce.objectId('orderId').optional(),
|
|
45
47
|
type: validation_1.ZodValidation.enumType(enum_1.ChatroomType, 'type'),
|
|
46
48
|
});
|
|
47
49
|
class ChatroomMessageSendSocketEvent extends BaseSocketEvent_1.BaseSocketEvent {
|
|
@@ -62,6 +64,7 @@ class ChatroomMessageSendSocketEvent extends BaseSocketEvent_1.BaseSocketEvent {
|
|
|
62
64
|
const pushPayload = {
|
|
63
65
|
lastMessage: payload.content,
|
|
64
66
|
chatroomId: payload.chatroomId,
|
|
67
|
+
orderId: payload.orderId,
|
|
65
68
|
type: payload.chatroomType,
|
|
66
69
|
};
|
|
67
70
|
const socketNotificationEvent = core_1.EventFactory.createEvent(enum_1.SocketEventType.NOTIFICATION, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatroom-message-send.socket.event.js","sourceRoot":"/","sources":["libraries/socket/events/chatroom-message-send.socket.event.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAoB;AACpB,kDAAuG;AACvG,8DAA6E;AAC7E,wDAAqD;AAErD,kCAAuC;AAE1B,QAAA,oCAAoC,GAAG,aAAC,CAAC,MAAM,CAAC;IAC5D,UAAU,EAAE,qBAAQ;CACpB,CAAC,CAAC;AAEU,QAAA,+BAA+B,GAAG,aAAC,CAAC,MAAM,CAAC;IACvD,GAAG,EAAE,0BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;IACzC,YAAY,EAAE,0BAAa,CAAC,QAAQ,CAAC,mBAAY,EAAE,cAAc,CAAC;IAClE,QAAQ,EAAE,0BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC;IACnD,UAAU,EAAE,0BAAa,CAAC,QAAQ,CAAC,cAAO,EAAE,YAAY,CAAC;IACzD,MAAM,EAAE,aAAC,CAAC,MAAM,CAAC;QAChB,EAAE,EAAE,0BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC9C,IAAI,EAAE,0BAAa,CAAC,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,EAAE,0BAAa,CAAC,QAAQ,CAAC,cAAO,EAAE,aAAa,CAAC;KACpD,CAAC;I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QAAQ,EAAE,IAAI,SAAS,CAAC;IACtD,CAAC;;
|
|
1
|
+
{"version":3,"file":"chatroom-message-send.socket.event.js","sourceRoot":"/","sources":["libraries/socket/events/chatroom-message-send.socket.event.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAoB;AACpB,kDAAuG;AACvG,8DAA6E;AAC7E,wDAAqD;AAErD,kCAAuC;AAE1B,QAAA,oCAAoC,GAAG,aAAC,CAAC,MAAM,CAAC;IAC5D,UAAU,EAAE,qBAAQ;CACpB,CAAC,CAAC;AAEU,QAAA,+BAA+B,GAAG,aAAC,CAAC,MAAM,CAAC;IACvD,GAAG,EAAE,0BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;IACzC,YAAY,EAAE,0BAAa,CAAC,QAAQ,CAAC,mBAAY,EAAE,cAAc,CAAC;IAClE,QAAQ,EAAE,0BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC;IACnD,UAAU,EAAE,0BAAa,CAAC,QAAQ,CAAC,cAAO,EAAE,YAAY,CAAC;IACzD,MAAM,EAAE,aAAC,CAAC,MAAM,CAAC;QAChB,EAAE,EAAE,0BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC9C,IAAI,EAAE,0BAAa,CAAC,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,EAAE,0BAAa,CAAC,QAAQ,CAAC,cAAO,EAAE,aAAa,CAAC;KACpD,CAAC;IACF,OAAO,EAAE,0BAAa,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE;IACnD,KAAK,EAAE,aAAC,CAAC,KAAK,CACb,aAAC,CAAC,MAAM,CAAC;QACR,QAAQ,EAAE,0BAAa,CAAC,MAAM,CAAC,UAAU,CAAC;QAC1C,SAAS,EAAE,0BAAa,CAAC,QAAQ,CAAC,gBAAS,EAAE,WAAW,CAAC;QACzD,QAAQ,EAAE,0BAAa,CAAC,MAAM,CAAC,KAAK,CAAC;QACrC,Y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, UserRef } from '../../../utilities/enum';\nimport { DTO, IdSchema, ZodValidation } from '../../../utilities/validation';\nimport { BaseSocketEvent } from '../BaseSocketEvent';\nimport { NotificationSettings } from '../PushNotificationEvent';\nimport { EventFactory } from '../core';\n\nexport const ChatroomMessageSendSocketInputSchema = z.object({\n\tchatroomId: IdSchema,\n});\n\nexport const ChatroomMessageSendOutputSchema = z.object({\n\t_id: ZodValidation.coerce.objectId('_id'),\n\tchatroomType: ZodValidation.enumType(ChatroomType, 'chatroomType'),\n\tsenderId: ZodValidation.coerce.objectId('senderId'), // DEPRECATED\n\tsenderType: ZodValidation.enumType(UserRef, 'senderType'), // DEPRECATED\n\tsender: z.object({\n\t\tid: ZodValidation.coerce.objectId('sender.id'),\n\t\tname: ZodValidation.string('senderName'),\n\t\ttype: ZodValidation.enumType(UserRef, 'sender.type'),\n\t}),\n\tcontent: ZodValidation.string('content').optional(),\n\tmedia: z.array(\n\t\tz.object({\n\t\t\tmimeType: ZodValidation.string('mimeType'),\n\t\t\tmediaType: ZodValidation.enumType(MediaType, 'mediaType'),\n\t\t\tmediaUrl: ZodValidation.string('url'),\n\t\t\tthumbnailUrl: ZodValidation.string('thumbnailUrl').optional(),\n\t\t\tname: ZodValidation.string('name').optional(),\n\t\t})\n\t),\n\tlocation: z\n\t\t.object({\n\t\t\tlongitude: ZodValidation.coerce.number('longitude').optional(),\n\t\t\tlatitude: ZodValidation.coerce.number('latitude').optional(),\n\t\t})\n\t\t.optional(),\n\tchatroomId: ZodValidation.coerce.objectId('chatroomId').optional(),\n\torderId: ZodValidation.coerce.objectId('orderId').optional(),\n\tcreatedAt: ZodValidation.coerce.date(),\n});\n\nexport const ChatroomMessageSendPushOutputSchema = z.object({\n\tlastMessage: ZodValidation.string('lastMessage').optional(),\n\tchatroomId: ZodValidation.coerce.objectId('chatroomId').optional(),\n\torderId: ZodValidation.coerce.objectId('orderId').optional(),\n\ttype: ZodValidation.enumType(ChatroomType, 'type'),\n});\n\nexport type ChatlistMessageSendPushOutputDTO = DTO<typeof ChatroomMessageSendPushOutputSchema>;\n\nexport type ChatroomMessageSendSocketOutputDTO = DTO<typeof ChatroomMessageSendOutputSchema>;\nexport type ChatroomMessageSendSocketInputDTO = DTO<typeof ChatroomMessageSendSocketInputSchema>;\n\nexport class ChatroomMessageSendSocketEvent extends BaseSocketEvent<\n\ttypeof ChatroomMessageSendSocketInputSchema,\n\ttypeof ChatroomMessageSendOutputSchema,\n\ttypeof ChatroomMessageSendPushOutputSchema\n> {\n\tstatic readonly schemas = {\n\t\tinput: ChatroomMessageSendSocketInputSchema,\n\t\toutput: ChatroomMessageSendOutputSchema,\n\t\tpushNotificationOutput: ChatroomMessageSendPushOutputSchema,\n\t};\n\n\tpublic get notificationSettings(): NotificationSettings | undefined {\n\t\treturn {\n\t\t\tisPushNotification: true,\n\t\t\tisClickable: true,\n\t\t\tclickType: ClickType.CLICKABLE_MESSAGE,\n\t\t\ttitle: this.getTitle(),\n\t\t};\n\t}\n\n\tconstructor(payload: ChatroomMessageSendSocketOutputDTO) {\n\t\tconst pushPayload: ChatlistMessageSendPushOutputDTO = {\n\t\t\tlastMessage: payload.content,\n\t\t\tchatroomId: payload.chatroomId,\n\t\t\torderId: payload.orderId,\n\t\t\ttype: payload.chatroomType,\n\t\t};\n\n\t\tconst socketNotificationEvent = EventFactory.createEvent(SocketEventType.NOTIFICATION, {\n\t\t\tmessage: 'New message!',\n\t\t\tnotificationType: SocketEventType.CHATROOM_MESSAGE_SEND,\n\t\t\t_id: payload._id,\n\t\t});\n\n\t\tsuper(\n\t\t\tSocketEventType.CHATROOM_MESSAGE_SEND,\n\t\t\tChatroomMessageSendSocketEvent.schemas,\n\t\t\tpayload,\n\t\t\tpushPayload,\n\t\t\tsocketNotificationEvent\n\t\t);\n\t}\n\n\tprivate getTitle(): string {\n\t\treturn this.payload().senderType === UserRef.ADMIN\n\t\t\t? 'New message from support'\n\t\t\t: this.payload().sender.name;\n\t}\n\n\tstatic identifier(input: z.infer<typeof ChatroomMessageSendSocketInputSchema>): string {\n\t\treturn input.chatroomId.toString();\n\t}\n\n\tpublic getPushNotificationPayload() {\n\t\treturn this.pushNotificationData;\n\t}\n\n\tprotected getIdentifier(): string {\n\t\treturn this.data.chatroomId?.toString() ?? 'default';\n\t}\n}\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED