@runnerpro/backend 1.12.1 → 1.12.2

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.
@@ -35,7 +35,6 @@ const index_2 = require("../../locale/index");
35
35
  const multer_1 = __importDefault(require("multer"));
36
36
  const axios_1 = __importDefault(require("axios"));
37
37
  const saveResponseTime_1 = require("../saveResponseTime");
38
- const sendMail_1 = require("../../sendMail");
39
38
  const fluent_ffmpeg_1 = __importDefault(require("fluent-ffmpeg"));
40
39
  const ffmpeg_static_1 = __importDefault(require("ffmpeg-static"));
41
40
  const ffprobe_static_1 = __importDefault(require("ffprobe-static"));
@@ -256,12 +255,6 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
256
255
  const { userid } = req.session;
257
256
  const filePath = path_1.default.join('./uploads', req.file.filename);
258
257
  if (req.file.mimetype.includes('video')) {
259
- (0, sendMail_1.sendMail)({
260
- to: ['david.jimenez@runnerpro.app'],
261
- subject: 'Video',
262
- body: JSON.stringify(req.file),
263
- title: '',
264
- });
265
258
  duration = yield getDurationFromVideo(filePath);
266
259
  }
267
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]);
@@ -281,12 +274,6 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
281
274
  else if (req.file.mimetype.includes('video')) {
282
275
  // Si es vídeo, se guarda el vídeo original, la duración y un thumbnail
283
276
  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
- });
290
277
  files.push({ data: fileData, id: idFile });
291
278
  files.push({ data: thumbnail, id: `${idFile}-thumbnail` });
292
279
  }
@@ -312,21 +299,9 @@ const getThumbnailFromVideo = (videoPath) => __awaiter(void 0, void 0, void 0, f
312
299
  const timestamp = 10;
313
300
  const size = '640x480';
314
301
  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
302
  const tempDir = path_1.default.join('./uploads');
322
303
  const outputFilename = `thumbnail_${Date.now()}.png`;
323
304
  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
305
  return new Promise((resolve, reject) => {
331
306
  (0, fluent_ffmpeg_1.default)(videoPath)
332
307
  .screenshots({
@@ -337,10 +312,29 @@ const getThumbnailFromVideo = (videoPath) => __awaiter(void 0, void 0, void 0, f
337
312
  quality,
338
313
  })
339
314
  .on('end', () => {
340
- console.log('Thumbnail generado:', outputPath);
341
- resolve(outputPath);
315
+ try {
316
+ // Leer el archivo como buffer
317
+ const buffer = fs_1.default.readFileSync(outputPath);
318
+ // Limpiar archivo temporal
319
+ fs_1.default.unlinkSync(outputPath);
320
+ console.log(`Thumbnail generado: ${buffer.length} bytes`);
321
+ resolve(buffer);
322
+ }
323
+ catch (error) {
324
+ console.error('Error leyendo archivo temporal:', error);
325
+ reject(error);
326
+ }
342
327
  })
343
328
  .on('error', (err) => {
329
+ // Limpiar archivo temporal en caso de error
330
+ try {
331
+ if (fs_1.default.existsSync(outputPath)) {
332
+ fs_1.default.unlinkSync(outputPath);
333
+ }
334
+ }
335
+ catch (cleanupError) {
336
+ console.error('Error limpiando archivo temporal:', cleanupError);
337
+ }
344
338
  console.error('Error generando thumbnail:', err);
345
339
  reject(err);
346
340
  });
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAmBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAoBpD,CAAC;AAyWF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.12.1",
3
+ "version": "1.12.2",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"