@runnerpro/backend 1.6.1 → 1.6.2

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,31 +13,27 @@ 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 = [];
16
17
  for (const device of devices) {
18
+ promises.push(
19
+ // @ts-ignore
17
20
  notificationWEB(firebaseMessaging, {
18
21
  title,
19
22
  body,
20
- }, device.subscription);
23
+ }, device.subscription));
21
24
  }
25
+ return promises;
22
26
  });
23
27
  exports.sendNotification = sendNotification;
24
28
  function notificationWEB(firebaseMessaging, msg, token) {
25
29
  return __awaiter(this, void 0, void 0, function* () {
26
30
  if (!msg.title)
27
31
  msg.title = '';
28
- firebaseMessaging
32
+ return firebaseMessaging
29
33
  .send({
30
34
  token,
31
35
  notification: msg,
32
36
  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
- }
41
37
  });
42
38
  });
43
39
  }
@@ -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<void>;
7
+ declare const sendNotification: ({ firebaseMessaging, idCliente, title, body }: Notification) => Promise<any[]>;
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,kBAa1F,CAAC;AAqBF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
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,mBAmB1F,CAAC;AAaF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"