@runnerpro/backend 1.12.19 → 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,14 +315,14 @@ 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* () {
|
|
321
|
-
const timestamp = 10;
|
|
318
|
+
const getThumbnailFromVideo = (videoPath, duration) => __awaiter(void 0, void 0, void 0, function* () {
|
|
322
319
|
const size = '640x480';
|
|
323
320
|
const quality = 2;
|
|
324
321
|
const tempDir = path_1.default.join('./uploads');
|
|
325
322
|
const outputFilename = `thumbnail_${Date.now()}.png`;
|
|
326
323
|
const outputPath = path_1.default.join(tempDir, outputFilename);
|
|
327
|
-
|
|
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);
|
|
328
326
|
return new Promise((resolve, reject) => {
|
|
329
327
|
(0, fluent_ffmpeg_1.default)(videoPath)
|
|
330
328
|
.screenshots({
|
|
@@ -337,12 +335,9 @@ const getThumbnailFromVideo = (videoPath) => __awaiter(void 0, void 0, void 0, f
|
|
|
337
335
|
.on('end', () => {
|
|
338
336
|
try {
|
|
339
337
|
// Leer el archivo como buffer
|
|
340
|
-
console.log('leer archivo como buffer');
|
|
341
338
|
const buffer = fs_1.default.readFileSync(outputPath);
|
|
342
|
-
console.log('leer archivo como buffer done');
|
|
343
339
|
// Limpiar archivo temporal
|
|
344
340
|
fs_1.default.unlinkSync(outputPath);
|
|
345
|
-
console.log('remove done');
|
|
346
341
|
resolve(buffer);
|
|
347
342
|
}
|
|
348
343
|
catch (error) {
|
|
@@ -413,17 +408,27 @@ const resizeImage = (data, filePath, mimetype) => __awaiter(void 0, void 0, void
|
|
|
413
408
|
const rotateOrientationImage = (data, filePath, image = null, mimetype) => __awaiter(void 0, void 0, void 0, function* () {
|
|
414
409
|
if (mimetype.includes('webp'))
|
|
415
410
|
return data;
|
|
416
|
-
|
|
417
|
-
|
|
411
|
+
let processedImage;
|
|
412
|
+
if (image) {
|
|
413
|
+
processedImage = image;
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
processedImage = yield jimp_1.default.read(filePath);
|
|
417
|
+
}
|
|
418
418
|
const orientation = yield exifr_1.default.orientation(data);
|
|
419
|
+
// Validar que orientation existe y es un número válido
|
|
420
|
+
if (typeof orientation !== 'number') {
|
|
421
|
+
return processedImage.getBufferAsync(jimp_1.default.MIME_JPEG);
|
|
422
|
+
}
|
|
419
423
|
let rotate;
|
|
420
424
|
if ([7, 8].includes(orientation))
|
|
421
425
|
rotate = 90;
|
|
422
426
|
else if ([3].includes(orientation))
|
|
423
427
|
rotate = 180;
|
|
424
|
-
else if ([5,
|
|
428
|
+
else if ([5, 6].includes(orientation))
|
|
425
429
|
rotate = -90;
|
|
426
|
-
if (rotate)
|
|
427
|
-
|
|
428
|
-
|
|
430
|
+
if (rotate) {
|
|
431
|
+
processedImage = yield processedImage.rotate(rotate);
|
|
432
|
+
}
|
|
433
|
+
return processedImage.getBufferAsync(jimp_1.default.MIME_JPEG);
|
|
429
434
|
});
|
|
@@ -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"}
|