@runnerpro/backend 1.4.2 → 1.4.4
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,7 +44,6 @@ 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)));
|
|
48
47
|
router.get('/conversation/suggestion', (req, res, next) => getConversationSuggestion(req, res).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
49
48
|
router.get('/conversation/image/:id', (req, res, next) => getConversationImage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
50
49
|
router.get('/conversation/file/:id', (req, res, next) => getConversationFile(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
@@ -75,6 +74,7 @@ const getConversation = (req, res, { query, isClient }) => __awaiter(void 0, voi
|
|
|
75
74
|
});
|
|
76
75
|
}
|
|
77
76
|
res.send({ header, messages });
|
|
77
|
+
console.log('read from getConversation');
|
|
78
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
79
|
if (isClient)
|
|
80
80
|
yield markReadMessage({ isClient, query, idCliente });
|
|
@@ -130,11 +130,6 @@ const getChatFile = ({ query, bucket, id, isClient, userid }) => __awaiter(void
|
|
|
130
130
|
return null;
|
|
131
131
|
}
|
|
132
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
|
-
});
|
|
138
133
|
const getConversationSuggestion = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
139
134
|
let result;
|
|
140
135
|
try {
|
|
@@ -160,6 +155,7 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
|
|
|
160
155
|
const { text } = req.body;
|
|
161
156
|
const { userid } = req.session;
|
|
162
157
|
const idCliente = isClient ? req.session.userid : req.body.idCliente;
|
|
158
|
+
console.log(1);
|
|
163
159
|
// Devuelve el texto en el otro idioma si el cliente no habla español y el idioma del cliente
|
|
164
160
|
const { textSpanish, textPreferredLanguage, preferredLanguage } = yield getPreferredLanguageForChat({
|
|
165
161
|
text,
|
|
@@ -167,7 +163,9 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
|
|
|
167
163
|
isClient,
|
|
168
164
|
query,
|
|
169
165
|
});
|
|
166
|
+
console.log(2);
|
|
170
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]);
|
|
168
|
+
console.log(3);
|
|
171
169
|
if (!isClient) {
|
|
172
170
|
sendNotification({
|
|
173
171
|
firebaseMessaging,
|
|
@@ -184,7 +182,9 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
|
|
|
184
182
|
},
|
|
185
183
|
});
|
|
186
184
|
}
|
|
185
|
+
console.log(4);
|
|
187
186
|
res.send({ status: 'ok' });
|
|
187
|
+
console.log('read from sendMessage');
|
|
188
188
|
// Si es entrenador, se marca leído cuando se envía un mensaje
|
|
189
189
|
if (!isClient)
|
|
190
190
|
yield markReadMessage({ isClient, query, idCliente });
|
|
@@ -245,10 +245,12 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, query, isClie
|
|
|
245
245
|
});
|
|
246
246
|
const readMessage = (req, res, { query, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
247
247
|
const { idCliente } = req.body;
|
|
248
|
+
console.log('read from readMessage');
|
|
248
249
|
yield markReadMessage({ isClient, query, idCliente });
|
|
249
250
|
res.send({ status: 'ok' });
|
|
250
251
|
});
|
|
251
252
|
const markReadMessage = ({ isClient, query, idCliente }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
253
|
+
console.log({ isClient, idCliente });
|
|
252
254
|
const conditionSender = isClient ? ' AND [ID SENDER] != ?' : ' AND [ID SENDER] = ?';
|
|
253
255
|
yield query('UPDATE [CHAT MESSAGE] SET [READ] = TRUE WHERE [ID CLIENTE] = ? AND [READ] = FALSE ' + conditionSender, [idCliente, idCliente]);
|
|
254
256
|
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,
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAmBpD,CAAC;AAmTF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|