@runnerpro/backend 1.12.20 → 1.12.21
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.
|
@@ -227,7 +227,6 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient }
|
|
|
227
227
|
idCliente,
|
|
228
228
|
isClient,
|
|
229
229
|
});
|
|
230
|
-
console.log(req.body);
|
|
231
230
|
// Enviado cuando es un mensaje de comentario sobre intelligence
|
|
232
231
|
if (newMessage) {
|
|
233
232
|
type = 6;
|
|
@@ -277,9 +276,8 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
|
|
|
277
276
|
const { userid } = req.session;
|
|
278
277
|
const filePath = path_1.default.join('./uploads', req.file.filename);
|
|
279
278
|
if (req.file.mimetype.includes('video')) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
console.log('duration and thumbnail done');
|
|
279
|
+
duration = yield getVideoDuration(filePath);
|
|
280
|
+
thumbnail = yield getThumbnailFromVideo(filePath, duration);
|
|
283
281
|
}
|
|
284
282
|
const [{ id: idFile }] = yield (0, index_1.query)('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [MIMETYPE], [DURATION], [TYPE]) VALUES (?, ?, ?, ?, ?, ?) RETURNING [ID]', [isClient ? userid : idCliente, userid, req.file.originalname, req.file.mimetype, duration || null, type || 2]);
|
|
285
283
|
const fileData = fs_1.default.readFileSync(filePath);
|
|
@@ -317,59 +315,47 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
|
|
|
317
315
|
});
|
|
318
316
|
}
|
|
319
317
|
});
|
|
320
|
-
const getThumbnailFromVideo = (videoPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
318
|
+
const getThumbnailFromVideo = (videoPath, duration) => __awaiter(void 0, void 0, void 0, function* () {
|
|
321
319
|
const size = '640x480';
|
|
322
320
|
const quality = 2;
|
|
323
321
|
const tempDir = path_1.default.join('./uploads');
|
|
324
322
|
const outputFilename = `thumbnail_${Date.now()}.png`;
|
|
325
323
|
const outputPath = path_1.default.join(tempDir, outputFilename);
|
|
326
|
-
|
|
324
|
+
// Usar el 10% de la duración o máximo 10 segundos, mínimo 1 segundo
|
|
325
|
+
const timestamp = Math.min(Math.max(duration * 0.1, 1), 10);
|
|
327
326
|
return new Promise((resolve, reject) => {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
327
|
+
(0, fluent_ffmpeg_1.default)(videoPath)
|
|
328
|
+
.screenshots({
|
|
329
|
+
timestamps: [timestamp],
|
|
330
|
+
filename: outputFilename,
|
|
331
|
+
folder: tempDir,
|
|
332
|
+
size,
|
|
333
|
+
quality,
|
|
334
|
+
})
|
|
335
|
+
.on('end', () => {
|
|
336
|
+
try {
|
|
337
|
+
// Leer el archivo como buffer
|
|
338
|
+
const buffer = fs_1.default.readFileSync(outputPath);
|
|
339
|
+
// Limpiar archivo temporal
|
|
340
|
+
fs_1.default.unlinkSync(outputPath);
|
|
341
|
+
resolve(buffer);
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
331
344
|
reject(error);
|
|
332
|
-
return;
|
|
333
345
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
.
|
|
339
|
-
timestamps: [timestamp],
|
|
340
|
-
filename: outputFilename,
|
|
341
|
-
folder: tempDir,
|
|
342
|
-
size,
|
|
343
|
-
quality,
|
|
344
|
-
})
|
|
345
|
-
.on('end', () => {
|
|
346
|
-
try {
|
|
347
|
-
// Leer el archivo como buffer
|
|
348
|
-
console.log('leer archivo como buffer');
|
|
349
|
-
const buffer = fs_1.default.readFileSync(outputPath);
|
|
350
|
-
console.log('leer archivo como buffer done');
|
|
351
|
-
// Limpiar archivo temporal
|
|
346
|
+
})
|
|
347
|
+
.on('error', (error) => {
|
|
348
|
+
// Limpiar archivo temporal en caso de error
|
|
349
|
+
try {
|
|
350
|
+
if (fs_1.default.existsSync(outputPath)) {
|
|
352
351
|
fs_1.default.unlinkSync(outputPath);
|
|
353
|
-
console.log('remove done');
|
|
354
|
-
resolve(buffer);
|
|
355
|
-
}
|
|
356
|
-
catch (error) {
|
|
357
|
-
reject(error);
|
|
358
352
|
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
//
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
catch (cleanupError) {
|
|
368
|
-
// eslint-disable-next-line no-console
|
|
369
|
-
console.error('Error limpiando archivo temporal:', cleanupError);
|
|
370
|
-
}
|
|
371
|
-
reject(error);
|
|
372
|
-
});
|
|
353
|
+
}
|
|
354
|
+
catch (cleanupError) {
|
|
355
|
+
// eslint-disable-next-line no-console
|
|
356
|
+
console.error('Error limpiando archivo temporal:', cleanupError);
|
|
357
|
+
}
|
|
358
|
+
reject(error);
|
|
373
359
|
});
|
|
374
360
|
});
|
|
375
361
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAuBpD,CAAC;
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAuBpD,CAAC;AAsaF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|