@runnerpro/backend 1.4.1 → 1.4.3

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.
@@ -74,7 +74,10 @@ const getConversation = (req, res, { query, isClient }) => __awaiter(void 0, voi
74
74
  });
75
75
  }
76
76
  res.send({ header, messages });
77
- markReadMessage({ isClient, query, idCliente });
77
+ console.log('read from getConversation');
78
+ // Solo se marca como leído si es el cliente | El entrenador tiene el botón o enviar mensaje para marcar como leído
79
+ if (isClient)
80
+ yield markReadMessage({ isClient, query, idCliente });
78
81
  });
79
82
  const getConversationImage = (req, res, { query, bucket, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
80
83
  const result = yield getChatFile({
@@ -177,6 +180,10 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
177
180
  });
178
181
  }
179
182
  res.send({ status: 'ok' });
183
+ console.log('read from sendMessage');
184
+ // Si es entrenador, se marca leído cuando se envía un mensaje
185
+ if (!isClient)
186
+ yield markReadMessage({ isClient, query, idCliente });
180
187
  });
181
188
  const getPreferredLanguageForChat = ({ text, idCliente, isClient, query }) => __awaiter(void 0, void 0, void 0, function* () {
182
189
  const [{ preferredLanguage }] = yield query('SELECT [PREFERRED LANGUAGE] FROM [CLIENTE] WHERE [ID] = ?', [idCliente]);
@@ -234,10 +241,12 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, query, isClie
234
241
  });
235
242
  const readMessage = (req, res, { query, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
236
243
  const { idCliente } = req.body;
244
+ console.log('read from readMessage');
237
245
  yield markReadMessage({ isClient, query, idCliente });
238
246
  res.send({ status: 'ok' });
239
247
  });
240
248
  const markReadMessage = ({ isClient, query, idCliente }) => __awaiter(void 0, void 0, void 0, function* () {
249
+ console.log({ isClient, idCliente });
241
250
  const conditionSender = isClient ? ' AND [ID SENDER] != ?' : ' AND [ID SENDER] = ?';
242
251
  yield query('UPDATE [CHAT MESSAGE] SET [READ] = TRUE WHERE [ID CLIENTE] = ? AND [READ] = FALSE ' + conditionSender, [idCliente, idCliente]);
243
252
  yield saveResponseTime({ query, isClient, idCliente });
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAmBpD,CAAC;AAkSF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAmBpD,CAAC;AA2SF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"