Добавить SHiNE теги в DM и безопасный рендер превью

This commit is contained in:
AidarKC
2026-07-10 18:57:44 +04:00
parent 076b43e542
commit 0d2d7b6dc5
10 changed files with 358 additions and 18 deletions
+10 -7
View File
@@ -1,4 +1,5 @@
import { addSignedMessageToChat, authService, authorizeSession, state } from '../state.js';
import { buildDmCallTechBlock } from './dm-tech-blocks.js';
const TYPES = {
INVITE: 100,
@@ -113,23 +114,25 @@ function isInviteUndelivered(call) {
function buildOutgoingCallSummaryText(call, summaryCode) {
if (!call || call.direction !== 'out') return '';
if (summaryCode === 'completed') {
const duration = formatDuration(nowMs() - Number(call.connectedAtMs || call.startedAtMs || nowMs()));
return `Звонок: ${duration}`;
return buildDmCallTechBlock({
status: 'completed',
durationSec: Math.round(Math.max(0, nowMs() - Number(call.connectedAtMs || call.startedAtMs || nowMs())) / 1000),
});
}
if (summaryCode === 'busy') {
return 'Звонил, но недозвонился: абонент занят';
return buildDmCallTechBlock({ status: 'failed', reason: 'busy' });
}
if (summaryCode === 'declined') {
return 'Звонил, но недозвонился: звонок отклонён';
return buildDmCallTechBlock({ status: 'failed', reason: 'declined' });
}
if (summaryCode === 'no_answer') {
if (isInviteUndelivered(call)) {
return 'Звонил, но недозвонился: абонент не в сети';
return buildDmCallTechBlock({ status: 'failed', reason: 'offline' });
}
return 'Звонил, но недозвонился: нет ответа';
return buildDmCallTechBlock({ status: 'failed', reason: 'no_answer' });
}
if (summaryCode === 'error') {
return 'Звонил, но недозвонился: не удалось установить соединение';
return buildDmCallTechBlock({ status: 'failed', reason: 'connect_failed' });
}
return '';
}