@runnerpro/backend 1.8.13 → 1.8.15

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.
@@ -44,12 +44,12 @@ const sendMessageChatToClient = (idCliente, text, textPreferredLanguage, preferr
44
44
  }
45
45
  yield (0, index_3.query)('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [TEXT PREFERRED LANGUAGE], [PREFERRED LANGUAGE], [TYPE]) VALUES (?, ?, ?, ?, ?, 1)', [idCliente, idEntrenador, text, textPreferredLanguage, preferredLanguage]);
46
46
  return {
47
- status: 'success',
48
- notification,
49
- options,
50
- firebaseMessaging: (0, messaging_1.getMessaging)(),
51
- body: (0, common_1.removeAccent)((textPreferredLanguage || text).substring(0, 50)) + ((textPreferredLanguage || text).length > 50 ? '...' : ''),
52
- screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
47
+ // status: 'success',
48
+ // notification,
49
+ // options,
50
+ // firebaseMessaging: getMessaging(),
51
+ // body: removeAccent((textPreferredLanguage || text).substring(0, 50)) + ((textPreferredLanguage || text).length > 50 ? '...' : ''),
52
+ // screen: NOTIFICATION_SCREEN_TYPES.CHAT,
53
53
  result,
54
54
  };
55
55
  });
@@ -24,38 +24,39 @@ const sendNotification = ({ firebaseMessaging, idCliente, title, body, screen =
24
24
  }),
25
25
  ]);
26
26
  const screenParamsString = JSON.stringify(screenParams);
27
+ const resultsDevices = [];
27
28
  for (const device of devices) {
28
- notificationWEB(firebaseMessaging, {
29
+ const resultDevice = yield notificationWEB(firebaseMessaging, {
29
30
  title,
30
31
  body,
31
32
  idNotification: (idNotification || '0').toString(),
32
33
  screen,
33
34
  screenParams: screenParamsString,
34
35
  }, device.subscription);
36
+ // @ts-ignore
37
+ resultsDevices.push(resultDevice);
35
38
  }
36
- return { status: 'success', idNotification, devices };
39
+ return { status: 'success', idNotification, devices, resultsDevices };
37
40
  });
38
41
  exports.sendNotification = sendNotification;
39
42
  function notificationWEB(firebaseMessaging, msg, token) {
40
43
  return __awaiter(this, void 0, void 0, function* () {
41
44
  if (!msg.title)
42
45
  msg.title = '';
43
- firebaseMessaging
44
- .send({
45
- token,
46
- notification: {
47
- title: msg.title,
48
- body: msg.body,
49
- },
50
- data: msg,
51
- })
52
- .catch((error) => {
53
- if (error.errorInfo.code === 'messaging/registration-token-not-registered') {
54
- // query(
55
- // 'DELETE FROM [PUSH MANAGER] WHERE [ID CLIENTE] = ? AND [SUBSCRIPTION] = ?',
56
- // [idCliente, subscription]
57
- // );
58
- }
59
- });
46
+ try {
47
+ const result = yield firebaseMessaging.send({
48
+ token,
49
+ notification: {
50
+ title: msg.title,
51
+ body: msg.body,
52
+ },
53
+ data: msg,
54
+ });
55
+ return result;
56
+ }
57
+ catch (error) {
58
+ console.log('Error al enviar notificación', error);
59
+ return error;
60
+ }
60
61
  });
61
62
  }
@@ -11,6 +11,7 @@ declare const sendNotification: ({ firebaseMessaging, idCliente, title, body, sc
11
11
  status: string;
12
12
  idNotification: any;
13
13
  devices: any;
14
+ resultsDevices: any[];
14
15
  }>;
15
16
  export { sendNotification };
16
17
  //# 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;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB;AAED,QAAA,MAAM,gBAAgB,yEAOnB,YAAY;;;;EAgCd,CAAC;AA4BF,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;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB;AAED,QAAA,MAAM,gBAAgB,yEAOnB,YAAY;;;;;EAmCd,CAAC;AAyBF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.8.13",
3
+ "version": "1.8.15",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"