This commit is contained in:
lendry
2026-07-10 10:37:22 +03:00
parent caf12e64f7
commit a4b4577c55
13 changed files with 669 additions and 48 deletions

View File

@@ -1,6 +1,6 @@
import { decryptBinary, decryptDirectMessage, encryptBinary, encryptDirectMessage } from '@/lib/e2e-crypto';
export type E2EMessageKind = 'text' | 'emoji' | 'image' | 'voice' | 'audio' | 'video' | 'video_note' | 'file';
export type E2EMessageKind = 'text' | 'emoji' | 'image' | 'voice' | 'audio' | 'video' | 'video_note' | 'file' | 'location';
export interface E2EMessagePayload {
kind: E2EMessageKind;
@@ -10,6 +10,10 @@ export interface E2EMessagePayload {
mimeType?: string;
fileSize?: number;
durationMs?: number;
latitude?: number;
longitude?: number;
address?: string;
label?: string;
}
export async function encryptE2EPayload(userId: string, peerPublicKey: string, payload: E2EMessagePayload) {
@@ -50,6 +54,8 @@ export function e2eKindFromMessageType(type: string): E2EMessageKind {
return 'video_note';
case 'FILE':
return 'file';
case 'LOCATION':
return 'location';
default:
return 'text';
}
@@ -74,6 +80,8 @@ export function readableE2EPayload(payload: E2EMessagePayload | null) {
return 'Кружок';
case 'file':
return payload.fileName ?? 'Файл';
case 'location':
return payload.label?.trim() || payload.address?.trim() || payload.text?.trim() || 'Геопозиция';
default:
return '🔒 Зашифрованное сообщение';
}