@runnerpro/backend 1.12.0 → 1.12.1
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.
|
@@ -36,6 +36,11 @@ const multer_1 = __importDefault(require("multer"));
|
|
|
36
36
|
const axios_1 = __importDefault(require("axios"));
|
|
37
37
|
const saveResponseTime_1 = require("../saveResponseTime");
|
|
38
38
|
const sendMail_1 = require("../../sendMail");
|
|
39
|
+
const fluent_ffmpeg_1 = __importDefault(require("fluent-ffmpeg"));
|
|
40
|
+
const ffmpeg_static_1 = __importDefault(require("ffmpeg-static"));
|
|
41
|
+
const ffprobe_static_1 = __importDefault(require("ffprobe-static"));
|
|
42
|
+
fluent_ffmpeg_1.default.setFfmpegPath(ffmpeg_static_1.default);
|
|
43
|
+
fluent_ffmpeg_1.default.setFfprobePath(ffprobe_static_1.default.path);
|
|
39
44
|
const conversationRoute = (_a) => {
|
|
40
45
|
var { router } = _a, params = __rest(_a, ["router"]);
|
|
41
46
|
const uploadFile = (0, multer_1.default)({
|
|
@@ -249,6 +254,7 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
|
|
|
249
254
|
const { idCliente, type } = req.body;
|
|
250
255
|
let { duration } = req.body;
|
|
251
256
|
const { userid } = req.session;
|
|
257
|
+
const filePath = path_1.default.join('./uploads', req.file.filename);
|
|
252
258
|
if (req.file.mimetype.includes('video')) {
|
|
253
259
|
(0, sendMail_1.sendMail)({
|
|
254
260
|
to: ['david.jimenez@runnerpro.app'],
|
|
@@ -256,10 +262,9 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
|
|
|
256
262
|
body: JSON.stringify(req.file),
|
|
257
263
|
title: '',
|
|
258
264
|
});
|
|
259
|
-
duration = yield getDurationFromVideo(
|
|
265
|
+
duration = yield getDurationFromVideo(filePath);
|
|
260
266
|
}
|
|
261
267
|
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]);
|
|
262
|
-
const filePath = path_1.default.join('./uploads', req.file.filename);
|
|
263
268
|
const fileData = fs_1.default.readFileSync(filePath);
|
|
264
269
|
const files = [];
|
|
265
270
|
if (req.file.mimetype.includes('image')) {
|
|
@@ -275,7 +280,13 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
|
|
|
275
280
|
}
|
|
276
281
|
else if (req.file.mimetype.includes('video')) {
|
|
277
282
|
// Si es vídeo, se guarda el vídeo original, la duración y un thumbnail
|
|
278
|
-
const thumbnail = yield getThumbnailFromVideo(
|
|
283
|
+
const thumbnail = yield getThumbnailFromVideo(filePath);
|
|
284
|
+
(0, sendMail_1.sendMail)({
|
|
285
|
+
to: ['david.jimenez@runnerpro.app'],
|
|
286
|
+
subject: 'Video 4',
|
|
287
|
+
body: JSON.stringify(thumbnail),
|
|
288
|
+
title: '',
|
|
289
|
+
});
|
|
279
290
|
files.push({ data: fileData, id: idFile });
|
|
280
291
|
files.push({ data: thumbnail, id: `${idFile}-thumbnail` });
|
|
281
292
|
}
|
|
@@ -297,13 +308,45 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
|
|
|
297
308
|
}
|
|
298
309
|
res.send({ idFile });
|
|
299
310
|
});
|
|
300
|
-
const getThumbnailFromVideo = (
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
311
|
+
const getThumbnailFromVideo = (videoPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
312
|
+
const timestamp = 10;
|
|
313
|
+
const size = '640x480';
|
|
314
|
+
const quality = 2;
|
|
315
|
+
(0, sendMail_1.sendMail)({
|
|
316
|
+
to: ['david.jimenez@runnerpro.app'],
|
|
317
|
+
subject: 'Video 2',
|
|
318
|
+
body: JSON.stringify(videoPath),
|
|
319
|
+
title: '',
|
|
320
|
+
});
|
|
321
|
+
const tempDir = path_1.default.join('./uploads');
|
|
322
|
+
const outputFilename = `thumbnail_${Date.now()}.png`;
|
|
323
|
+
const outputPath = path_1.default.join(tempDir, outputFilename);
|
|
324
|
+
(0, sendMail_1.sendMail)({
|
|
325
|
+
to: ['david.jimenez@runnerpro.app'],
|
|
326
|
+
subject: 'Video 3',
|
|
327
|
+
body: JSON.stringify({ tempDir, outputFilename, outputPath }),
|
|
328
|
+
title: '',
|
|
329
|
+
});
|
|
330
|
+
return new Promise((resolve, reject) => {
|
|
331
|
+
(0, fluent_ffmpeg_1.default)(videoPath)
|
|
332
|
+
.screenshots({
|
|
333
|
+
timestamps: [timestamp],
|
|
334
|
+
filename: outputFilename,
|
|
335
|
+
folder: tempDir,
|
|
336
|
+
size,
|
|
337
|
+
quality,
|
|
338
|
+
})
|
|
339
|
+
.on('end', () => {
|
|
340
|
+
console.log('Thumbnail generado:', outputPath);
|
|
341
|
+
resolve(outputPath);
|
|
342
|
+
})
|
|
343
|
+
.on('error', (err) => {
|
|
344
|
+
console.error('Error generando thumbnail:', err);
|
|
345
|
+
reject(err);
|
|
346
|
+
});
|
|
347
|
+
});
|
|
305
348
|
});
|
|
306
|
-
const getDurationFromVideo = (
|
|
349
|
+
const getDurationFromVideo = (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
307
350
|
return 10;
|
|
308
351
|
});
|
|
309
352
|
const readMessage = (req, res, { 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":"
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAoBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAoBpD,CAAC;AA+WF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runnerpro/backend",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"description": "A collection of common backend functions",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/cjs/index.js"
|
|
@@ -66,11 +66,13 @@
|
|
|
66
66
|
"@google-cloud/translate": "^8.3.0",
|
|
67
67
|
"@notionhq/client": "^2.2.15",
|
|
68
68
|
"exifr": "^7.1.3",
|
|
69
|
+
"ffmpeg-static": "^5.2.0",
|
|
70
|
+
"ffprobe-static": "^3.1.0",
|
|
69
71
|
"firebase-admin": "^11.10.1",
|
|
72
|
+
"fluent-ffmpeg": "^2.1.3",
|
|
70
73
|
"googleapis": "^144.0.0",
|
|
71
74
|
"multer": "^1.4.5-lts.1",
|
|
72
75
|
"oauth-signature": "1.5.0",
|
|
73
76
|
"socket.io": "^4.7.2"
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
|
-
|