@runnerpro/backend 1.15.5 → 1.15.7

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.
@@ -270,7 +270,7 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient }
270
270
  firebaseMessaging,
271
271
  idCliente,
272
272
  title: '💬 Nuevo mensaje de tu entrenador',
273
- body: `Rubén: ${textPreferredLanguage || textSpanish}`,
273
+ body: textPreferredLanguage || textSpanish,
274
274
  screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
275
275
  });
276
276
  // Enviar a N8N lo que ha escrito el entrenador
@@ -292,8 +292,18 @@ const updateSenderView = ({ userid, idCliente, idMessage }) => __awaiter(void 0,
292
292
  let idSenderView;
293
293
  if (cliente.idEntrenadorPrincipal === userid)
294
294
  idSenderView = cliente.idEntrenadorPrincipal;
295
- else
296
- idSenderView = Math.random() < 0.4 ? cliente.idEntrenadorPrincipal : cliente.idEntrenadorSecundario; // 40% entrenador principal o 60% entrenador secundario
295
+ else {
296
+ const [prevMessage] = yield (0, index_1.query)('SELECT [ID SENDER VIEW], [ID SENDER], [ID CLIENTE] FROM [CHAT MESSAGE] WHERE [ID] != ? AND [ID CLIENTE] = ? ORDER BY [ID] DESC LIMIT 1', [idMessage, idCliente]);
297
+ // Si el mensaje anterior es del cliente o no tiene idSenderView, se elige un entrenador al azar
298
+ if (prevMessage.idSender === prevMessage.idCliente || !prevMessage.idSenderView) {
299
+ // 40% entrenador principal o 60% entrenador secundario;
300
+ idSenderView = Math.random() < 0.4 ? cliente.idEntrenadorPrincipal : cliente.idEntrenadorSecundario;
301
+ }
302
+ else {
303
+ // Si el mensaje anterior es del entrenador, se pone el mismo entrenador que el mensaje anterior
304
+ idSenderView = prevMessage.idSenderView;
305
+ }
306
+ }
297
307
  yield (0, index_1.query)('UPDATE [CHAT MESSAGE] SET [ID SENDER VIEW] = ? WHERE [ID] = ?', [idSenderView, idMessage]);
298
308
  });
299
309
  exports.updateSenderView = updateSenderView;
@@ -396,7 +406,7 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
396
406
  firebaseMessaging,
397
407
  idCliente,
398
408
  title: (0, index_2.t)('💬 Nuevo mensaje de tu entrenador', cliente.preferredLanguage),
399
- body: `Rubén: ${(0, index_2.t)(textFile, cliente.preferredLanguage)}`,
409
+ body: (0, index_2.t)(textFile, cliente.preferredLanguage),
400
410
  screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
401
411
  });
402
412
  yield updateSenderView({ userid, idCliente, idMessage: idFile });
@@ -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;AA6PF,QAAA,MAAM,gBAAgB;;;;mBAQrB,CAAC;AAsRF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,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;AA6PF,QAAA,MAAM,gBAAgB;;;;mBAkBrB,CAAC;AAsRF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.15.5",
3
+ "version": "1.15.7",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"