@runnerpro/backend 1.12.25 → 1.12.26
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.
|
@@ -276,17 +276,10 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
|
|
|
276
276
|
const { userid } = req.session;
|
|
277
277
|
const filePath = path_1.default.join('./uploads', req.file.filename);
|
|
278
278
|
if (req.file.mimetype.includes('video')) {
|
|
279
|
-
console.time('getVideoDuration');
|
|
280
279
|
duration = yield getVideoDuration(filePath);
|
|
281
|
-
console.timeEnd('getVideoDuration');
|
|
282
|
-
console.time('getThumbnailFromVideo');
|
|
283
280
|
thumbnail = yield getThumbnailFromVideo(filePath, duration);
|
|
284
|
-
console.timeEnd('getThumbnailFromVideo');
|
|
285
281
|
}
|
|
286
|
-
console.time('query');
|
|
287
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]);
|
|
288
|
-
console.timeEnd('query');
|
|
289
|
-
console.time('readFileSync');
|
|
290
283
|
const fileData = fs_1.default.readFileSync(filePath);
|
|
291
284
|
const files = [];
|
|
292
285
|
if (req.file.mimetype.includes('image')) {
|
|
@@ -307,13 +300,10 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
|
|
|
307
300
|
else {
|
|
308
301
|
files.push({ data: fileData, id: idFile });
|
|
309
302
|
}
|
|
310
|
-
console.timeEnd('readFileSync');
|
|
311
303
|
res.send({ idFile });
|
|
312
|
-
console.time('saveFile');
|
|
313
304
|
for (const file of files) {
|
|
314
305
|
yield bucket.file(`Chat/${file.id}`).save(file.data);
|
|
315
306
|
}
|
|
316
|
-
console.timeEnd('saveFile');
|
|
317
307
|
fs_1.default.unlinkSync(filePath);
|
|
318
308
|
if (!isClient) {
|
|
319
309
|
const [cliente] = yield (0, index_1.query)('SELECT [PREFERRED LANGUAGE] FROM [CLIENTE] WHERE [ID] = ?', [idCliente]);
|
|
@@ -328,7 +318,6 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
|
|
|
328
318
|
const getThumbnailFromVideo = (videoPath, duration) => __awaiter(void 0, void 0, void 0, function* () {
|
|
329
319
|
const targetWidth = 500;
|
|
330
320
|
const targetHeight = 400;
|
|
331
|
-
const quality = 2;
|
|
332
321
|
const tempDir = path_1.default.join('./uploads');
|
|
333
322
|
const outputFilename = `thumbnail_${Date.now()}.png`;
|
|
334
323
|
const outputPath = path_1.default.join(tempDir, outputFilename);
|
|
@@ -423,27 +412,17 @@ const resizeImage = (data, filePath, mimetype) => __awaiter(void 0, void 0, void
|
|
|
423
412
|
const rotateOrientationImage = (data, filePath, image = null, mimetype) => __awaiter(void 0, void 0, void 0, function* () {
|
|
424
413
|
if (mimetype.includes('webp'))
|
|
425
414
|
return data;
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
processedImage = image;
|
|
429
|
-
}
|
|
430
|
-
else {
|
|
431
|
-
processedImage = yield jimp_1.default.read(filePath);
|
|
432
|
-
}
|
|
415
|
+
if (!image)
|
|
416
|
+
image = yield jimp_1.default.read(filePath);
|
|
433
417
|
const orientation = yield exifr_1.default.orientation(data);
|
|
434
|
-
// Validar que orientation existe y es un número válido
|
|
435
|
-
if (typeof orientation !== 'number') {
|
|
436
|
-
return processedImage.getBufferAsync(jimp_1.default.MIME_JPEG);
|
|
437
|
-
}
|
|
438
418
|
let rotate;
|
|
439
419
|
if ([7, 8].includes(orientation))
|
|
440
420
|
rotate = 90;
|
|
441
421
|
else if ([3].includes(orientation))
|
|
442
422
|
rotate = 180;
|
|
443
|
-
else if ([5,
|
|
423
|
+
else if ([5, 8].includes(orientation))
|
|
444
424
|
rotate = -90;
|
|
445
|
-
if (rotate)
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
return processedImage.getBufferAsync(jimp_1.default.MIME_JPEG);
|
|
425
|
+
if (rotate)
|
|
426
|
+
image = yield image.rotate(rotate);
|
|
427
|
+
return image.getBufferAsync(jimp_1.default.MIME_JPEG);
|
|
449
428
|
});
|
|
@@ -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;AAuZF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|