@runnerpro/backend 1.8.14 → 1.8.16

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.
@@ -26,10 +26,9 @@ const sendMessageChatToClient = (idCliente, text, textPreferredLanguage, preferr
26
26
  return;
27
27
  idEntrenador = entrenadorBBDD.idEntrenador;
28
28
  }
29
- let result;
30
29
  if (notification) {
31
30
  try {
32
- result = yield (0, index_2.sendNotification)({
31
+ yield (0, index_2.sendNotification)({
33
32
  firebaseMessaging: (0, messaging_1.getMessaging)(),
34
33
  idCliente,
35
34
  body: (0, common_1.removeAccent)((textPreferredLanguage || text).substring(0, 50)) + ((textPreferredLanguage || text).length > 50 ? '...' : ''),
@@ -37,20 +36,9 @@ const sendMessageChatToClient = (idCliente, text, textPreferredLanguage, preferr
37
36
  });
38
37
  }
39
38
  catch (e) {
40
- console.log('Error al enviar notificación', e);
41
39
  (0, index_1.err)(null, null, e, null);
42
- return e;
43
40
  }
44
41
  }
45
42
  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
- return {
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
- result,
54
- };
55
43
  });
56
44
  exports.sendMessageChatToClient = sendMessageChatToClient;
@@ -25,7 +25,7 @@ const sendNotification = ({ firebaseMessaging, idCliente, title, body, screen =
25
25
  ]);
26
26
  const screenParamsString = JSON.stringify(screenParams);
27
27
  for (const device of devices) {
28
- notificationWEB(firebaseMessaging, {
28
+ yield notificationWEB(firebaseMessaging, {
29
29
  title,
30
30
  body,
31
31
  idNotification: (idNotification || '0').toString(),
@@ -33,29 +33,24 @@ const sendNotification = ({ firebaseMessaging, idCliente, title, body, screen =
33
33
  screenParams: screenParamsString,
34
34
  }, device.subscription);
35
35
  }
36
- return { status: 'success', idNotification, devices };
37
36
  });
38
37
  exports.sendNotification = sendNotification;
39
38
  function notificationWEB(firebaseMessaging, msg, token) {
40
39
  return __awaiter(this, void 0, void 0, function* () {
41
40
  if (!msg.title)
42
41
  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
- });
42
+ try {
43
+ yield firebaseMessaging.send({
44
+ token,
45
+ notification: {
46
+ title: msg.title,
47
+ body: msg.body,
48
+ },
49
+ data: msg,
50
+ });
51
+ }
52
+ catch (error) {
53
+ console.log('Error al enviar notificación', error);
54
+ }
60
55
  });
61
56
  }
@@ -1,3 +1,3 @@
1
- declare const sendMessageChatToClient: (idCliente: any, text: any, textPreferredLanguage: any, preferredLanguage: any, options: any) => Promise<any>;
1
+ declare const sendMessageChatToClient: (idCliente: any, text: any, textPreferredLanguage: any, preferredLanguage: any, options: any) => Promise<void>;
2
2
  export { sendMessageChatToClient };
3
3
  //# sourceMappingURL=sendMessageChatToClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sendMessageChatToClient.d.ts","sourceRoot":"","sources":["../../../../src/chat/sendMessageChatToClient.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,uBAAuB,+GAuC5B,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"sendMessageChatToClient.d.ts","sourceRoot":"","sources":["../../../../src/chat/sendMessageChatToClient.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,uBAAuB,gHA2B5B,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -7,10 +7,6 @@ interface Notification {
7
7
  screen?: string;
8
8
  screenParams?: any;
9
9
  }
10
- declare const sendNotification: ({ firebaseMessaging, idCliente, title, body, screen, screenParams, }: Notification) => Promise<{
11
- status: string;
12
- idNotification: any;
13
- devices: any;
14
- }>;
10
+ declare const sendNotification: ({ firebaseMessaging, idCliente, title, body, screen, screenParams, }: Notification) => Promise<void>;
15
11
  export { sendNotification };
16
12
  //# 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,kBA8Bd,CAAC;AAuBF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.8.14",
3
+ "version": "1.8.16",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"