@runnerpro/backend 1.4.1 → 1.4.2

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.
@@ -44,6 +44,7 @@ const conversationRoute = (_a) => {
44
44
  },
45
45
  });
46
46
  router.get('/conversation', (req, res, next) => getConversation(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
47
+ router.post('/conversation/mark-as-read', (req, res, next) => markAsRead(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
47
48
  router.get('/conversation/suggestion', (req, res, next) => getConversationSuggestion(req, res).catch((error) => (0, index_1.err)(req, res, error, next)));
48
49
  router.get('/conversation/image/:id', (req, res, next) => getConversationImage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
49
50
  router.get('/conversation/file/:id', (req, res, next) => getConversationFile(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
@@ -74,7 +75,9 @@ const getConversation = (req, res, { query, isClient }) => __awaiter(void 0, voi
74
75
  });
75
76
  }
76
77
  res.send({ header, messages });
77
- markReadMessage({ isClient, query, idCliente });
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({
@@ -127,6 +130,11 @@ const getChatFile = ({ query, bucket, id, isClient, userid }) => __awaiter(void
127
130
  return null;
128
131
  }
129
132
  });
133
+ const markAsRead = (req, res, { query, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
134
+ const { idCliente } = req.body;
135
+ yield markReadMessage({ isClient, query, idCliente });
136
+ res.send({ status: 'ok' });
137
+ });
130
138
  const getConversationSuggestion = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
131
139
  let result;
132
140
  try {
@@ -177,6 +185,9 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
177
185
  });
178
186
  }
179
187
  res.send({ status: 'ok' });
188
+ // Si es entrenador, se marca leído cuando se envía un mensaje
189
+ if (!isClient)
190
+ yield markReadMessage({ isClient, query, idCliente });
180
191
  });
181
192
  const getPreferredLanguageForChat = ({ text, idCliente, isClient, query }) => __awaiter(void 0, void 0, void 0, function* () {
182
193
  const [{ preferredLanguage }] = yield query('SELECT [PREFERRED LANGUAGE] FROM [CLIENTE] WHERE [ID] = ?', [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,SAoBpD,CAAC;AA6SF,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.2",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"