фикс багов

This commit is contained in:
Халимов Рустам
2026-03-10 23:16:44 +03:00
parent be0c3812fc
commit 540ded7009
12 changed files with 346 additions and 148 deletions

View File

@@ -59,8 +59,11 @@ app.use('/uploads', (req, res, next) => {
const contentType = mime.lookup(filePath) || 'application/octet-stream';
res.setHeader('Content-Type', contentType);
// If encryption is enabled, try to decrypt
if (isEncryptionEnabled()) {
// Check if we should skip decryption (videos/audio always skipped for range support)
const isMedia = contentType.startsWith('video/') || contentType.startsWith('audio/');
// If encryption is enabled and NOT video/audio, try to decrypt
if (isEncryptionEnabled() && !isMedia) {
const decrypted = decryptFileToBuffer(filePath);
if (decrypted) {
res.setHeader('Content-Length', decrypted.length);

View File

@@ -135,7 +135,7 @@ export const uploadFile = multer({
cb(null, `${uuidv4()}${ext}`);
},
}),
limits: { fileSize: 50 * 1024 * 1024 },
limits: { fileSize: 200 * 1024 * 1024 },
fileFilter: (_req, file, cb) => {
const ext = path.extname(file.originalname).toLowerCase();
if (BLOCKED_EXTENSIONS.has(ext)) {
@@ -158,15 +158,20 @@ export function encryptUploadedFile(req: Request, _res: Response, next: NextFunc
try {
// Single file upload (req.file)
if (req.file) {
encryptFileInPlace(req.file.path);
// Don't encrypt videos and audio as they need range support and are large
if (!req.file.mimetype.startsWith('video/') && !req.file.mimetype.startsWith('audio/')) {
encryptFileInPlace(req.file.path);
}
}
// Multiple files (req.files) — handle both array and field-keyed forms
if (req.files) {
const files = Array.isArray(req.files)
? req.files
: Object.values(req.files).flat();
: Object.values(req.files).flat() as Express.Multer.File[];
for (const file of files) {
encryptFileInPlace(file.path);
if (!file.mimetype.startsWith('video/') && !file.mimetype.startsWith('audio/')) {
encryptFileInPlace(file.path);
}
}
}
} catch (e) {

View File

@@ -779,6 +779,15 @@ export function setupSocket(io: Server) {
}
});
socket.on('call_type_changed', (data: { targetUserId: string; callType: 'voice' | 'video' }) => {
const targetSockets = onlineUsers.get(data.targetUserId);
if (targetSockets) {
for (const sid of targetSockets) {
io.to(sid).emit('call_type_changed', { from: userId, callType: data.callType });
}
}
});
// ======= Group Conference Calls =======
// Query active group call status for a chat