@runnerpro/backend 1.14.15 → 1.14.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.
@@ -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 });
105
+ yield markReadMessage({ isClient, idCliente, query: index_1.query });
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 }) => __awaiter(void 0, void 0, void 0, function* () {
237
+ const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient, query }) => __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
- getPreferredLanguageForChat({ text, idCliente, isClient }),
248
+ markReadMessage({ idCliente, query, 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,7 +259,7 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient }
259
259
  type = 6;
260
260
  idWorkout = newMessage.idWorkout;
261
261
  }
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]);
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]);
263
263
  res.send({ idMessage: message.id, text: textSpanish });
264
264
  if (!isClient) {
265
265
  sendNotification({
@@ -446,14 +446,14 @@ const getVideoDuration = (videoPath) => __awaiter(void 0, void 0, void 0, functi
446
446
  });
447
447
  });
448
448
  });
449
- const readMessage = (req, res, { isClient }) => __awaiter(void 0, void 0, void 0, function* () {
449
+ const readMessage = (req, res, { isClient, query }) => __awaiter(void 0, void 0, void 0, function* () {
450
450
  const { idCliente } = req.body;
451
- yield markReadMessage({ isClient, idCliente });
451
+ yield markReadMessage({ isClient, idCliente, query });
452
452
  res.send({ status: 'ok' });
453
453
  });
454
- const markReadMessage = ({ isClient, idCliente }) => __awaiter(void 0, void 0, void 0, function* () {
454
+ const markReadMessage = ({ isClient, idCliente, query }) => __awaiter(void 0, void 0, void 0, function* () {
455
455
  const conditionSender = isClient ? ' AND [ID SENDER] != ?' : ' AND ([ID SENDER] = ? OR [ID SENDER] IS NULL)';
456
- yield (0, index_1.query)('UPDATE [CHAT MESSAGE] SET [READ] = TRUE WHERE [ID CLIENTE] = ? AND [READ] = FALSE ' + conditionSender, [idCliente, idCliente]);
456
+ yield query('UPDATE [CHAT MESSAGE] SET [READ] = TRUE WHERE [ID CLIENTE] = ? AND [READ] = FALSE ' + conditionSender, [idCliente, idCliente]);
457
457
  if (!isClient)
458
458
  yield (0, saveResponseTime_1.saveResponseTime)(idCliente);
459
459
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.14.15",
3
+ "version": "1.14.16",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"