@runnerpro/backend 1.6.2 → 1.6.4
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.
|
@@ -13,27 +13,31 @@ exports.sendNotification = void 0;
|
|
|
13
13
|
const index_1 = require("../db/index");
|
|
14
14
|
const sendNotification = ({ firebaseMessaging, idCliente, title, body }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
15
|
const devices = yield (0, index_1.query)('SELECT [SUBSCRIPTION], [TYPE] FROM [PUSH MANAGER] WHERE [ID CLIENTE] = ?', [idCliente]);
|
|
16
|
-
const promises = [];
|
|
17
16
|
for (const device of devices) {
|
|
18
|
-
promises.push(
|
|
19
|
-
// @ts-ignore
|
|
20
17
|
notificationWEB(firebaseMessaging, {
|
|
21
18
|
title,
|
|
22
19
|
body,
|
|
23
|
-
}, device.subscription)
|
|
20
|
+
}, device.subscription);
|
|
24
21
|
}
|
|
25
|
-
return promises;
|
|
26
22
|
});
|
|
27
23
|
exports.sendNotification = sendNotification;
|
|
28
24
|
function notificationWEB(firebaseMessaging, msg, token) {
|
|
29
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
26
|
if (!msg.title)
|
|
31
27
|
msg.title = '';
|
|
32
|
-
|
|
28
|
+
firebaseMessaging
|
|
33
29
|
.send({
|
|
34
30
|
token,
|
|
35
31
|
notification: msg,
|
|
36
32
|
data: msg,
|
|
33
|
+
})
|
|
34
|
+
.catch((error) => {
|
|
35
|
+
if (error.errorInfo.code === 'messaging/registration-token-not-registered') {
|
|
36
|
+
// query(
|
|
37
|
+
// 'DELETE FROM [PUSH MANAGER] WHERE [ID CLIENTE] = ? AND [SUBSCRIPTION] = ?',
|
|
38
|
+
// [idCliente, subscription]
|
|
39
|
+
// );
|
|
40
|
+
}
|
|
37
41
|
});
|
|
38
42
|
});
|
|
39
43
|
}
|
|
@@ -4,6 +4,6 @@ interface Notification {
|
|
|
4
4
|
title?: string;
|
|
5
5
|
body: string;
|
|
6
6
|
}
|
|
7
|
-
declare const sendNotification: ({ firebaseMessaging, idCliente, title, body }: Notification) => Promise<
|
|
7
|
+
declare const sendNotification: ({ firebaseMessaging, idCliente, title, body }: Notification) => Promise<void>;
|
|
8
8
|
export { sendNotification };
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendNotification/index.ts"],"names":[],"mappings":"AAEA,UAAU,YAAY;IACpB,iBAAiB,EAAE,GAAG,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,QAAA,MAAM,gBAAgB,kDAAyD,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendNotification/index.ts"],"names":[],"mappings":"AAEA,UAAU,YAAY;IACpB,iBAAiB,EAAE,GAAG,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,QAAA,MAAM,gBAAgB,kDAAyD,YAAY,kBAa1F,CAAC;AAqBF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|