@runnerpro/backend 1.4.12 → 1.5.0

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.
@@ -151,7 +151,7 @@ const getConversationSuggestion = (req, res) => __awaiter(void 0, void 0, void 0
151
151
  }
152
152
  });
153
153
  const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
154
- const { text } = req.body;
154
+ const { text, replyMessageId } = req.body;
155
155
  const { userid } = req.session;
156
156
  const idCliente = isClient ? req.session.userid : req.body.idCliente;
157
157
  // Si es entrenador, se marca leído cuando se envía un mensaje
@@ -164,7 +164,7 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
164
164
  isClient,
165
165
  query,
166
166
  });
167
- yield query('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [TEXT PREFERRED LANGUAGE], [PREFERRED LANGUAGE], [TYPE]) VALUES (?, ?, ?, ?, ?, 1)', [isClient ? userid : idCliente, userid, textSpanish, textPreferredLanguage, preferredLanguage]);
167
+ yield query('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [TEXT PREFERRED LANGUAGE], [PREFERRED LANGUAGE], [RESPUESTA ID], [TYPE]) VALUES (?, ?, ?, ?, ?, ?, ?)', [isClient ? userid : idCliente, userid, textSpanish, textPreferredLanguage, preferredLanguage, replyMessageId, 1]);
168
168
  if (!isClient) {
169
169
  sendNotification({
170
170
  firebaseMessaging,
@@ -183,6 +183,7 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
183
183
  });
184
184
  }
185
185
  catch (error) {
186
+ // eslint-disable-next-line no-console
186
187
  console.error(error);
187
188
  }
188
189
  }
@@ -248,7 +249,7 @@ const readMessage = (req, res, { query, isClient }) => __awaiter(void 0, void 0,
248
249
  res.send({ status: 'ok' });
249
250
  });
250
251
  const markReadMessage = ({ isClient, query, idCliente }) => __awaiter(void 0, void 0, void 0, function* () {
251
- const conditionSender = isClient ? ' AND [ID SENDER] != ?' : ' AND [ID SENDER] = ?';
252
+ const conditionSender = isClient ? ' AND [ID SENDER] != ?' : ' AND ([ID SENDER] = ? || [ID SENDER] IS NULL)';
252
253
  yield query('UPDATE [CHAT MESSAGE] SET [READ] = TRUE WHERE [ID CLIENTE] = ? AND [READ] = FALSE ' + conditionSender, [idCliente, idCliente]);
253
254
  yield saveResponseTime({ query, isClient, idCliente });
254
255
  });
@@ -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;AA0SF,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.12",
3
+ "version": "1.5.0",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"