@runnerpro/backend 1.4.8 → 1.4.10
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.
|
@@ -155,7 +155,9 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
|
|
|
155
155
|
const { text } = req.body;
|
|
156
156
|
const { userid } = req.session;
|
|
157
157
|
const idCliente = isClient ? req.session.userid : req.body.idCliente;
|
|
158
|
-
|
|
158
|
+
// Si es entrenador, se marca leído cuando se envía un mensaje
|
|
159
|
+
if (!isClient)
|
|
160
|
+
yield markReadMessage({ isClient, query, idCliente });
|
|
159
161
|
// Devuelve el texto en el otro idioma si el cliente no habla español y el idioma del cliente
|
|
160
162
|
const { textSpanish, textPreferredLanguage, preferredLanguage } = yield getPreferredLanguageForChat({
|
|
161
163
|
text,
|
|
@@ -163,9 +165,7 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
|
|
|
163
165
|
isClient,
|
|
164
166
|
query,
|
|
165
167
|
});
|
|
166
|
-
console.log(2);
|
|
167
168
|
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);
|
|
169
169
|
if (!isClient) {
|
|
170
170
|
sendNotification({
|
|
171
171
|
firebaseMessaging,
|
|
@@ -173,8 +173,8 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
|
|
|
173
173
|
body: `Rubén: ${textPreferredLanguage || textSpanish}`,
|
|
174
174
|
url: '/chat',
|
|
175
175
|
});
|
|
176
|
-
// Enviar el mensaje a la IA de vuelta para que aprenda que mensaje ha acabado enviando el entrenador
|
|
177
176
|
try {
|
|
177
|
+
// Enviar el mensaje a la IA de vuelta para que aprenda que mensaje ha acabado enviando el entrenador
|
|
178
178
|
yield axios_1.default.put(`${process.env.BACKEND_IA_URL}/api/chat/suggestion`, { userId: idCliente }, {
|
|
179
179
|
headers: {
|
|
180
180
|
'ngrok-skip-browser-warning': true, // working with ngrok
|
|
@@ -187,12 +187,7 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
|
|
|
187
187
|
console.error(error);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
console.log(4);
|
|
191
190
|
res.send({ status: 'ok' });
|
|
192
|
-
console.log('read from sendMessage');
|
|
193
|
-
// Si es entrenador, se marca leído cuando se envía un mensaje
|
|
194
|
-
if (!isClient)
|
|
195
|
-
yield markReadMessage({ isClient, query, idCliente });
|
|
196
191
|
});
|
|
197
192
|
const getPreferredLanguageForChat = ({ text, idCliente, isClient, query }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
198
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;
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAmBpD,CAAC;AAoTF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|