@runnerpro/backend 1.5.9 → 1.5.11

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.
@@ -16,22 +16,23 @@ exports.sendNotification = void 0;
16
16
  const node_apn_1 = __importDefault(require("@parse/node-apn"));
17
17
  const index_1 = require("../db/index");
18
18
  const sendMail_1 = require("../sendMail");
19
- const sendNotification = ({ firebaseMessaging, idCliente, title, body, url }) => __awaiter(void 0, void 0, void 0, function* () {
19
+ const sendNotification = ({ firebaseMessaging, idCliente, title, body }) => __awaiter(void 0, void 0, void 0, function* () {
20
20
  const devices = yield (0, index_1.query)('SELECT [SUBSCRIPTION], [TYPE] FROM [PUSH MANAGER] WHERE [ID CLIENTE] = ?', [idCliente]);
21
21
  for (const device of devices) {
22
- if (device.type === 'IOS') {
23
- notificationIOS({
24
- title,
25
- body,
26
- }, device.subscription);
27
- }
28
- else {
29
- notificationWEB(firebaseMessaging, {
30
- title,
31
- body,
32
- url: process.env.FRONTEND_URL + url,
33
- }, device.subscription);
34
- }
22
+ /*if (['IOS', 'ios'].includes(device.type)) {
23
+ notificationIOS(
24
+ {
25
+ title,
26
+ body,
27
+ },
28
+ device.subscription
29
+ );
30
+ } else { */
31
+ notificationWEB(firebaseMessaging, {
32
+ title,
33
+ body
34
+ }, device.subscription);
35
+ // }
35
36
  }
36
37
  });
37
38
  exports.sendNotification = sendNotification;
@@ -83,7 +84,16 @@ function notificationWEB(firebaseMessaging, msg, token) {
83
84
  firebaseMessaging
84
85
  .send({
85
86
  token,
87
+ notification: msg,
86
88
  data: msg,
89
+ })
90
+ .then((response) => {
91
+ (0, sendMail_1.sendMail)({
92
+ to: ['david.jimenez@runnerpro.app'],
93
+ subject: 'Notificación APN enviada',
94
+ title: 'Notificación APN enviada ' + token,
95
+ body: JSON.stringify(response),
96
+ });
87
97
  })
88
98
  .catch((error) => {
89
99
  if (error.errorInfo.code === 'messaging/registration-token-not-registered') {
@@ -92,6 +102,12 @@ function notificationWEB(firebaseMessaging, msg, token) {
92
102
  // [idCliente, subscription]
93
103
  // );
94
104
  }
105
+ (0, sendMail_1.sendMail)({
106
+ to: ['david.jimenez@runnerpro.app'],
107
+ subject: 'Error enviando notificación APN',
108
+ title: 'Error enviando notificación APN ' + token,
109
+ body: JSON.stringify(error),
110
+ });
95
111
  });
96
112
  });
97
113
  }
@@ -3,8 +3,7 @@ interface Notification {
3
3
  idCliente: number;
4
4
  title?: string;
5
5
  body: string;
6
- url: string;
7
6
  }
8
- declare const sendNotification: ({ firebaseMessaging, idCliente, title, body, url }: Notification) => Promise<void>;
7
+ declare const sendNotification: ({ firebaseMessaging, idCliente, title, body }: Notification) => Promise<void>;
9
8
  export { sendNotification };
10
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendNotification/index.ts"],"names":[],"mappings":"AAIA,UAAU,YAAY;IACpB,iBAAiB,EAAE,GAAG,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED,QAAA,MAAM,gBAAgB,uDAA8D,YAAY,kBAwB/F,CAAC;AA+DF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendNotification/index.ts"],"names":[],"mappings":"AAIA,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,kBAuB1F,CAAC;AA8EF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.5.9",
3
+ "version": "1.5.11",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"