@runnerpro/backend 1.12.3 → 1.12.5

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.
@@ -252,12 +252,14 @@ const getPreferredLanguageForChat = ({ text, idCliente, isClient }) => __awaiter
252
252
  const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, bucket }) => __awaiter(void 0, void 0, void 0, function* () {
253
253
  const { idCliente, type } = req.body;
254
254
  let { duration } = req.body;
255
+ let thumbnail;
255
256
  const { userid } = req.session;
256
257
  const filePath = path_1.default.join('./uploads', req.file.filename);
257
258
  if (req.file.mimetype.includes('video')) {
258
- duration = yield getVideoDuration(filePath);
259
+ [duration, thumbnail] = yield Promise.all([getVideoDuration(filePath), getThumbnailFromVideo(filePath)]);
259
260
  }
260
261
  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
+ res.send({ idFile });
261
263
  const fileData = fs_1.default.readFileSync(filePath);
262
264
  const files = [];
263
265
  if (req.file.mimetype.includes('image')) {
@@ -272,8 +274,6 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
272
274
  }
273
275
  }
274
276
  else if (req.file.mimetype.includes('video')) {
275
- // Si es vídeo, se guarda el vídeo original, la duración y un thumbnail
276
- const thumbnail = yield getThumbnailFromVideo(filePath);
277
277
  files.push({ data: fileData, id: idFile });
278
278
  files.push({ data: thumbnail, id: `${idFile}-thumbnail` });
279
279
  }
@@ -293,7 +293,6 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, isClient, buc
293
293
  screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
294
294
  });
295
295
  }
296
- res.send({ idFile });
297
296
  });
298
297
  const getThumbnailFromVideo = (videoPath) => __awaiter(void 0, void 0, void 0, function* () {
299
298
  const timestamp = 10;
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAoBpD,CAAC;AAgYF,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",
3
+ "version": "1.12.5",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"