@runnerpro/backend 1.12.6 → 1.12.8
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.
|
@@ -53,6 +53,7 @@ const conversationRoute = (_a) => {
|
|
|
53
53
|
router.delete('/conversation/:id', (req, res, next) => deleteConversationMessage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
54
54
|
router.put('/conversation/:id', (req, res, next) => editConversationMessage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
55
55
|
router.get('/conversation/image/:id', (req, res, next) => getConversationImage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
56
|
+
router.get('/conversation/thumbnail/:id', (req, res, next) => getConversationThumbnail(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
56
57
|
router.get('/conversation/file/:id', (req, res, next) => getConversationFile(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
57
58
|
router.post('/conversation/send', (req, res, next) => sendMessage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
58
59
|
router.post('/conversation/send-file', uploadFile.single('file'), (req, res, next) => sendFile(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
@@ -166,6 +167,22 @@ const getConversationImage = (req, res, { bucket, isClient }) => __awaiter(void
|
|
|
166
167
|
mimetype: result.message.mimetype,
|
|
167
168
|
});
|
|
168
169
|
});
|
|
170
|
+
const getConversationThumbnail = (req, res, { bucket, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
171
|
+
const { id: idVideo } = req.params;
|
|
172
|
+
const [file] = yield bucket.file(`Chat/${idVideo}-thumbnail`).exists();
|
|
173
|
+
if (!file)
|
|
174
|
+
return res.status(404).send('Not found');
|
|
175
|
+
const [thumbnail] = yield bucket.file(`Chat/${idVideo}-thumbnail`).download();
|
|
176
|
+
res.writeHead(200, {
|
|
177
|
+
'Content-Type': 'image/jpeg',
|
|
178
|
+
'Content-disposition': 'inline',
|
|
179
|
+
'Content-Length': file.length,
|
|
180
|
+
});
|
|
181
|
+
res.end({
|
|
182
|
+
file: thumbnail.toString('base64'),
|
|
183
|
+
mimetype: 'image/jpeg',
|
|
184
|
+
});
|
|
185
|
+
});
|
|
169
186
|
const getConversationFile = (req, res, { bucket, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
170
187
|
const result = yield getChatFile({
|
|
171
188
|
bucket,
|
|
@@ -316,15 +333,13 @@ const getThumbnailFromVideo = (videoPath) => __awaiter(void 0, void 0, void 0, f
|
|
|
316
333
|
const buffer = fs_1.default.readFileSync(outputPath);
|
|
317
334
|
// Limpiar archivo temporal
|
|
318
335
|
fs_1.default.unlinkSync(outputPath);
|
|
319
|
-
console.log(`Thumbnail generado: ${buffer.length} bytes`);
|
|
320
336
|
resolve(buffer);
|
|
321
337
|
}
|
|
322
338
|
catch (error) {
|
|
323
|
-
console.error('Error leyendo archivo temporal:', error);
|
|
324
339
|
reject(error);
|
|
325
340
|
}
|
|
326
341
|
})
|
|
327
|
-
.on('error', (
|
|
342
|
+
.on('error', (error) => {
|
|
328
343
|
// Limpiar archivo temporal en caso de error
|
|
329
344
|
try {
|
|
330
345
|
if (fs_1.default.existsSync(outputPath)) {
|
|
@@ -332,19 +347,18 @@ const getThumbnailFromVideo = (videoPath) => __awaiter(void 0, void 0, void 0, f
|
|
|
332
347
|
}
|
|
333
348
|
}
|
|
334
349
|
catch (cleanupError) {
|
|
350
|
+
// eslint-disable-next-line no-console
|
|
335
351
|
console.error('Error limpiando archivo temporal:', cleanupError);
|
|
336
352
|
}
|
|
337
|
-
|
|
338
|
-
reject(err);
|
|
353
|
+
reject(error);
|
|
339
354
|
});
|
|
340
355
|
});
|
|
341
356
|
});
|
|
342
357
|
const getVideoDuration = (videoPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
343
358
|
return new Promise((resolve, reject) => {
|
|
344
|
-
fluent_ffmpeg_1.default.ffprobe(videoPath, (
|
|
345
|
-
if (
|
|
346
|
-
|
|
347
|
-
reject(err);
|
|
359
|
+
fluent_ffmpeg_1.default.ffprobe(videoPath, (error, metadata) => {
|
|
360
|
+
if (error) {
|
|
361
|
+
reject(error);
|
|
348
362
|
return;
|
|
349
363
|
}
|
|
350
364
|
try {
|
|
@@ -355,9 +369,8 @@ const getVideoDuration = (videoPath) => __awaiter(void 0, void 0, void 0, functi
|
|
|
355
369
|
const durationInSeconds = Math.round(parseFloat(duration));
|
|
356
370
|
resolve(durationInSeconds);
|
|
357
371
|
}
|
|
358
|
-
catch (
|
|
359
|
-
|
|
360
|
-
reject(error);
|
|
372
|
+
catch (errorCatch) {
|
|
373
|
+
reject(errorCatch);
|
|
361
374
|
}
|
|
362
375
|
});
|
|
363
376
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAuBpD,CAAC;AA4YF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|