@runnerpro/backend 1.14.16 → 1.14.17

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.
@@ -102,7 +102,7 @@ const getConversation = (req, res, { isClient }) => __awaiter(void 0, void 0, vo
102
102
  res.send({ header, messages });
103
103
  // Solo se marca como leído si es el cliente | El entrenador tiene el botón o enviar mensaje para marcar como leído
104
104
  if (isClient)
105
- yield markReadMessage({ isClient, idCliente, query: index_1.query });
105
+ yield markReadMessage({ isClient, idCliente });
106
106
  });
107
107
  const fillReacciones = (message, reacciones) => {
108
108
  message.reacciones = reacciones
@@ -234,7 +234,7 @@ const getChatFile = ({ bucket, id, isClient, userid }) => __awaiter(void 0, void
234
234
  return null;
235
235
  }
236
236
  });
237
- const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient, query }) => __awaiter(void 0, void 0, void 0, function* () {
237
+ const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
238
238
  const { replyMessageId, new: newMessage } = req.body;
239
239
  let { text } = req.body;
240
240
  const { userid } = req.session;
@@ -245,7 +245,7 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient,
245
245
  // Cambiar el tono del texto a uno neutro y corregir la ortografía
246
246
  cambiarTonoEntrenadorNeutro(text),
247
247
  // Si es entrenador, se marca leído cuando se envía un mensaje
248
- markReadMessage({ idCliente, query, isClient }),
248
+ markReadMessage({ idCliente, isClient }),
249
249
  ]);
250
250
  }
251
251
  // Devuelve el texto en el otro idioma si el cliente no habla español y el idioma del cliente
@@ -259,12 +259,13 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient,
259
259
  type = 6;
260
260
  idWorkout = newMessage.idWorkout;
261
261
  }
262
- const [message] = yield query('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [TEXT PREFERRED LANGUAGE], [PREFERRED LANGUAGE], [REPLY MESSAGE ID], [ID WORKOUT], [TYPE]) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING [ID]', [isClient ? userid : idCliente, userid, textSpanish, textPreferredLanguage, preferredLanguage, replyMessageId, idWorkout, type]);
262
+ const [message] = yield (0, index_1.query)('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [TEXT PREFERRED LANGUAGE], [PREFERRED LANGUAGE], [REPLY MESSAGE ID], [ID WORKOUT], [TYPE]) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING [ID]', [isClient ? userid : idCliente, userid, textSpanish, textPreferredLanguage, preferredLanguage, replyMessageId, idWorkout, type]);
263
263
  res.send({ idMessage: message.id, text: textSpanish });
264
264
  if (!isClient) {
265
265
  sendNotification({
266
266
  firebaseMessaging,
267
267
  idCliente,
268
+ title: '💬 Nuevo mensaje de tu entrenador',
268
269
  body: `Rubén: ${textPreferredLanguage || textSpanish}`,
269
270
  screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
270
271
  });
@@ -368,11 +369,19 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
368
369
  }
369
370
  fs_1.default.unlinkSync(filePath);
370
371
  if (!isClient) {
372
+ let textFile = 'Archivo adjunto';
373
+ if (Number(type) === 4)
374
+ textFile = 'Audio';
375
+ if (req.file.mimetype.includes('video'))
376
+ textFile = 'Vídeo';
377
+ if (req.file.mimetype.includes('image'))
378
+ textFile = 'Imagen';
371
379
  const [cliente] = yield (0, index_1.query)('SELECT [PREFERRED LANGUAGE] FROM [CLIENTE] WHERE [ID] = ?', [idCliente]);
372
380
  sendNotification({
373
381
  firebaseMessaging,
374
382
  idCliente,
375
- body: `Rubén: ${(0, index_2.t)(Number(type) === 4 ? 'Audio' : 'Archivo adjunto', cliente.preferredLanguage)}`,
383
+ title: (0, index_2.t)('💬 Nuevo mensaje de tu entrenador', cliente.preferredLanguage),
384
+ body: `Rubén: ${(0, index_2.t)(textFile, cliente.preferredLanguage)}`,
376
385
  screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
377
386
  });
378
387
  }
@@ -446,14 +455,14 @@ const getVideoDuration = (videoPath) => __awaiter(void 0, void 0, void 0, functi
446
455
  });
447
456
  });
448
457
  });
449
- const readMessage = (req, res, { isClient, query }) => __awaiter(void 0, void 0, void 0, function* () {
458
+ const readMessage = (req, res, { isClient }) => __awaiter(void 0, void 0, void 0, function* () {
450
459
  const { idCliente } = req.body;
451
- yield markReadMessage({ isClient, idCliente, query });
460
+ yield markReadMessage({ isClient, idCliente });
452
461
  res.send({ status: 'ok' });
453
462
  });
454
- const markReadMessage = ({ isClient, idCliente, query }) => __awaiter(void 0, void 0, void 0, function* () {
463
+ const markReadMessage = ({ isClient, idCliente }) => __awaiter(void 0, void 0, void 0, function* () {
455
464
  const conditionSender = isClient ? ' AND [ID SENDER] != ?' : ' AND ([ID SENDER] = ? OR [ID SENDER] IS NULL)';
456
- yield query('UPDATE [CHAT MESSAGE] SET [READ] = TRUE WHERE [ID CLIENTE] = ? AND [READ] = FALSE ' + conditionSender, [idCliente, idCliente]);
465
+ yield (0, index_1.query)('UPDATE [CHAT MESSAGE] SET [READ] = TRUE WHERE [ID CLIENTE] = ? AND [READ] = FALSE ' + conditionSender, [idCliente, idCliente]);
457
466
  if (!isClient)
458
467
  yield (0, saveResponseTime_1.saveResponseTime)(idCliente);
459
468
  });
@@ -44,7 +44,8 @@ const sendMessageChatToClient = (idCliente, text, textPreferredLanguage, preferr
44
44
  yield (0, index_2.sendNotification)({
45
45
  firebaseMessaging: (0, messaging_1.getMessaging)(),
46
46
  idCliente,
47
- body: (0, common_1.removeAccent)((textPreferredLanguage || text).substring(0, 50)) + ((textPreferredLanguage || text).length > 50 ? '...' : ''),
47
+ title: '💬 Nuevo mensaje de tu entrenador',
48
+ body: `Rubén: ${textPreferredLanguage || text}`,
48
49
  screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
49
50
  });
50
51
  }
@@ -4,5 +4,8 @@ exports.en = void 0;
4
4
  const en = {
5
5
  'Archivo adjunto': 'Attached file',
6
6
  Audio: 'Audio',
7
+ Vídeo: 'Video',
8
+ Imagen: 'Image',
9
+ '💬 Nuevo mensaje de tu entrenador': '💬 New message from your trainer',
7
10
  };
8
11
  exports.en = en;
@@ -4,5 +4,8 @@ exports.es = void 0;
4
4
  const es = {
5
5
  'Archivo adjunto': 'Archivo adjunto',
6
6
  Audio: 'Audio',
7
+ Vídeo: 'Vídeo',
8
+ Imagen: 'Imagen',
9
+ '💬 Nuevo mensaje de tu entrenador': '💬 Nuevo mensaje de tu entrenador',
7
10
  };
8
11
  exports.es = es;
@@ -4,5 +4,8 @@ exports.fr = void 0;
4
4
  const fr = {
5
5
  'Archivo adjunto': 'Pièce jointe',
6
6
  Audio: 'Audio',
7
+ Vídeo: 'Vidéo',
8
+ Imagen: 'Image',
9
+ '💬 Nuevo mensaje de tu entrenador': '💬 Nouveau message de votre entraîneur',
7
10
  };
8
11
  exports.fr = fr;
@@ -4,5 +4,8 @@ exports.it = void 0;
4
4
  const it = {
5
5
  'Archivo adjunto': 'File allegato',
6
6
  Audio: 'Audio',
7
+ Vídeo: 'Video',
8
+ Imagen: 'Immagine',
9
+ '💬 Nuevo mensaje de tu entrenador': '💬 Nuovo messaggio da tuo allenatore',
7
10
  };
8
11
  exports.it = it;
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SA0BpD,CAAC;AA+fF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SA0BpD,CAAC;AAqgBF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sendMessageChatToClient.d.ts","sourceRoot":"","sources":["../../../../src/chat/sendMessageChatToClient.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,uBAAuB,gHAyC5B,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"sendMessageChatToClient.d.ts","sourceRoot":"","sources":["../../../../src/chat/sendMessageChatToClient.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,uBAAuB,gHA0C5B,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -1,6 +1,9 @@
1
1
  declare const en: {
2
2
  'Archivo adjunto': string;
3
3
  Audio: string;
4
+ Vídeo: string;
5
+ Imagen: string;
6
+ '\uD83D\uDCAC Nuevo mensaje de tu entrenador': string;
4
7
  };
5
8
  export { en };
6
9
  //# sourceMappingURL=en.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/locale/en.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,EAAE;;;CAGP,CAAC;AAEF,OAAO,EAAE,EAAE,EAAE,CAAC"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/locale/en.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,EAAE;;;;;;CAMP,CAAC;AAEF,OAAO,EAAE,EAAE,EAAE,CAAC"}
@@ -1,6 +1,9 @@
1
1
  declare const es: {
2
2
  'Archivo adjunto': string;
3
3
  Audio: string;
4
+ Vídeo: string;
5
+ Imagen: string;
6
+ '\uD83D\uDCAC Nuevo mensaje de tu entrenador': string;
4
7
  };
5
8
  export { es };
6
9
  //# sourceMappingURL=es.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../../../../src/locale/es.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,EAAE;;;CAGP,CAAC;AAEF,OAAO,EAAE,EAAE,EAAE,CAAC"}
1
+ {"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../../../../src/locale/es.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,EAAE;;;;;;CAMP,CAAC;AAEF,OAAO,EAAE,EAAE,EAAE,CAAC"}
@@ -1,6 +1,9 @@
1
1
  declare const fr: {
2
2
  'Archivo adjunto': string;
3
3
  Audio: string;
4
+ Vídeo: string;
5
+ Imagen: string;
6
+ '\uD83D\uDCAC Nuevo mensaje de tu entrenador': string;
4
7
  };
5
8
  export { fr };
6
9
  //# sourceMappingURL=fr.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fr.d.ts","sourceRoot":"","sources":["../../../../src/locale/fr.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,EAAE;;;CAGP,CAAC;AAEF,OAAO,EAAE,EAAE,EAAE,CAAC"}
1
+ {"version":3,"file":"fr.d.ts","sourceRoot":"","sources":["../../../../src/locale/fr.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,EAAE;;;;;;CAMP,CAAC;AAEF,OAAO,EAAE,EAAE,EAAE,CAAC"}
@@ -1,6 +1,9 @@
1
1
  declare const it: {
2
2
  'Archivo adjunto': string;
3
3
  Audio: string;
4
+ Vídeo: string;
5
+ Imagen: string;
6
+ '\uD83D\uDCAC Nuevo mensaje de tu entrenador': string;
4
7
  };
5
8
  export { it };
6
9
  //# sourceMappingURL=it.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"it.d.ts","sourceRoot":"","sources":["../../../../src/locale/it.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,EAAE;;;CAGP,CAAC;AAEF,OAAO,EAAE,EAAE,EAAE,CAAC"}
1
+ {"version":3,"file":"it.d.ts","sourceRoot":"","sources":["../../../../src/locale/it.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,EAAE;;;;;;CAMP,CAAC;AAEF,OAAO,EAAE,EAAE,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.14.16",
3
+ "version": "1.14.17",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"