@runnerpro/backend 1.13.22 → 1.13.23
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.
|
@@ -33,7 +33,6 @@ const index_1 = require("../../index");
|
|
|
33
33
|
const common_1 = require("@runnerpro/common");
|
|
34
34
|
const index_2 = require("../../locale/index");
|
|
35
35
|
const multer_1 = __importDefault(require("multer"));
|
|
36
|
-
const axios_1 = __importDefault(require("axios"));
|
|
37
36
|
const saveResponseTime_1 = require("../saveResponseTime");
|
|
38
37
|
const fluent_ffmpeg_1 = __importDefault(require("fluent-ffmpeg"));
|
|
39
38
|
const ffmpeg_static_1 = __importDefault(require("ffmpeg-static"));
|
|
@@ -221,26 +220,33 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient }
|
|
|
221
220
|
const idCliente = isClient ? req.session.userid : req.body.idCliente;
|
|
222
221
|
let idWorkout, type = 1;
|
|
223
222
|
if (!isClient) {
|
|
223
|
+
console.time('markReadMessage');
|
|
224
224
|
// Si es entrenador, se marca leído cuando se envía un mensaje
|
|
225
225
|
yield markReadMessage({ isClient, idCliente });
|
|
226
|
+
console.timeEnd('markReadMessage');
|
|
226
227
|
// Cambiar el tono del texto a uno neutro y corregir la ortografía
|
|
227
228
|
if (idCliente === 'sJzhGqaJcddq96x80hZAlPJ6pET2' && process.env.NODE_ENV === 'PROD') {
|
|
228
|
-
console.
|
|
229
|
+
console.time('cambiarTonoEntrenadorNeutro');
|
|
229
230
|
text = yield cambiarTonoEntrenadorNeutro(text);
|
|
231
|
+
console.timeEnd('cambiarTonoEntrenadorNeutro');
|
|
230
232
|
}
|
|
231
233
|
}
|
|
232
234
|
// Devuelve el texto en el otro idioma si el cliente no habla español y el idioma del cliente
|
|
235
|
+
console.time('getPreferredLanguageForChat');
|
|
233
236
|
const { textSpanish, textPreferredLanguage, preferredLanguage } = yield getPreferredLanguageForChat({
|
|
234
237
|
text,
|
|
235
238
|
idCliente,
|
|
236
239
|
isClient,
|
|
237
240
|
});
|
|
241
|
+
console.timeEnd('getPreferredLanguageForChat');
|
|
238
242
|
// Enviado cuando es un mensaje de comentario sobre intelligence
|
|
239
243
|
if (newMessage) {
|
|
240
244
|
type = 6;
|
|
241
245
|
idWorkout = newMessage.idWorkout;
|
|
242
246
|
}
|
|
247
|
+
console.time('query');
|
|
243
248
|
const [message] = yield (0, index_1.query)('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [TEXT PREFERRED LANGUAGE], [PREFERRED LANGUAGE], [REPLY MESSAGE ID], [ID WORKOUT], [TYPE]) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING [ID]', [isClient ? userid : idCliente, userid, textSpanish, textPreferredLanguage, preferredLanguage, replyMessageId, idWorkout, type]);
|
|
249
|
+
console.timeEnd('query');
|
|
244
250
|
res.send({ idMessage: message.id, text: textSpanish });
|
|
245
251
|
if (!isClient) {
|
|
246
252
|
sendNotification({
|
|
@@ -250,13 +256,16 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient }
|
|
|
250
256
|
screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
|
|
251
257
|
});
|
|
252
258
|
// Enviar a N8N lo que ha escrito el entrenador
|
|
253
|
-
const [lastSuggestionMsg] =
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
259
|
+
// const [lastSuggestionMsg] = await query(
|
|
260
|
+
// 'SELECT [ID] FROM [CHAT MESSAGE] WHERE [ID CLIENTE] = ? AND [SUGGESTION TEXT] IS NOT NULL ORDER BY [ID] DESC LIMIT 1',
|
|
261
|
+
// [idCliente]
|
|
262
|
+
// );
|
|
263
|
+
// if (lastSuggestionMsg) {
|
|
264
|
+
// await axios.put(`${process.env.N8N_URL}/edc2484f-7010-44c1-8c1d-82924496a2eb`, {
|
|
265
|
+
// id: lastSuggestionMsg.id,
|
|
266
|
+
// msg: textSpanish,
|
|
267
|
+
// });
|
|
268
|
+
// }
|
|
260
269
|
}
|
|
261
270
|
});
|
|
262
271
|
const getPreferredLanguageForChat = ({ text, idCliente, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAmBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAuBpD,CAAC;
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAmBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAuBpD,CAAC;AA0bF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|