@runnerpro/backend 1.12.2 → 1.12.3
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.
|
@@ -255,7 +255,7 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
|
|
|
255
255
|
const { userid } = req.session;
|
|
256
256
|
const filePath = path_1.default.join('./uploads', req.file.filename);
|
|
257
257
|
if (req.file.mimetype.includes('video')) {
|
|
258
|
-
duration = yield
|
|
258
|
+
duration = yield getVideoDuration(filePath);
|
|
259
259
|
}
|
|
260
260
|
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]);
|
|
261
261
|
const fileData = fs_1.default.readFileSync(filePath);
|
|
@@ -340,8 +340,29 @@ const getThumbnailFromVideo = (videoPath) => __awaiter(void 0, void 0, void 0, f
|
|
|
340
340
|
});
|
|
341
341
|
});
|
|
342
342
|
});
|
|
343
|
-
const
|
|
344
|
-
return
|
|
343
|
+
const getVideoDuration = (videoPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
344
|
+
return new Promise((resolve, reject) => {
|
|
345
|
+
fluent_ffmpeg_1.default.ffprobe(videoPath, (err, metadata) => {
|
|
346
|
+
if (err) {
|
|
347
|
+
console.error('Error con ffprobe:', err);
|
|
348
|
+
reject(err);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
try {
|
|
352
|
+
const duration = metadata.format.duration;
|
|
353
|
+
if (!duration || isNaN(duration)) {
|
|
354
|
+
throw new Error('No se pudo obtener la duración del video');
|
|
355
|
+
}
|
|
356
|
+
const durationInSeconds = parseFloat(duration);
|
|
357
|
+
console.log(`Duración del video: ${durationInSeconds} segundos`);
|
|
358
|
+
resolve(durationInSeconds);
|
|
359
|
+
}
|
|
360
|
+
catch (error) {
|
|
361
|
+
console.error('Error procesando metadata:', error);
|
|
362
|
+
reject(error);
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
});
|
|
345
366
|
});
|
|
346
367
|
const readMessage = (req, res, { isClient }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
347
368
|
const { idCliente } = req.body;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAoBpD,CAAC;AAiYF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|