Spaces:
Running
Running
Update routes/chats.js
Browse files405 unmodified lines406407408409410411412413414415115 unmodified lines531532533534405 unmodified lineslastCallDuration: d.lastCallDuration || 0,lastCallWithVideo: d.lastCallWithVideo || false,isLastMessageRead: d.unreadCounts ? (d.unreadCounts[user.username] || 0) === 0 : true,isRoom: false};}).filter(Boolean);const roomResults = roomsRaw.map(r => {const contactActions = r.actions || [];let previewText = r.type === 'channel' ? st('Канал', lang) : st('Группа', lang);115 unmodified lines} catch (e) { res.status(500).json({ error: 'Error' }); }});module.exports = router;405 unmodified lines406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443115 unmodified lines559560561562405 unmodified lineslastCallDuration: d.lastCallDuration || 0,lastCallWithVideo: d.lastCallWithVideo || false,isLastMessageRead: d.unreadCounts ? (d.unreadCounts[user.username] || 0) === 0 : true,isRoom: false,previousText: d.previousText || null};}).filter(Boolean);const e2eeDialogs = dialogs.filter(d => d.lastText === '🔒');if (e2eeDialogs.length > 0) {const prevMsgs = await Message.aggregate([{ $match: {$or: e2eeDialogs.map(d => ({dialog_id: getDialogId(username, d.username),is_encrypted: { $ne: true },isService: { $ne: true },expires_at: null}))}},{ $sort: { timestamp: -1 } },{ $group: {_id: '$dialog_id',text: { $first: '$text' }}}]);const prevMap = {};for (const pm of prevMsgs) {prevMap[pm._id] = clarify(pm.text || '');}for (const d of e2eeDialogs) {const prevText = prevMap[getDialogId(username, d.username)];if (prevText) d.previousText = prevText;}}const roomResults = roomsRaw.map(r => {const contactActions = r.actions || [];let previewText = r.type === 'channel' ? st('Канал', lang) : st('Группа', lang);115 unmodified lines} catch (e) { res.status(500).json({ error: 'Error' }); }});module.exports = router;
routes/chats.js+30-2