Fix files, delete, edit in DMs

This commit is contained in:
2025-09-24 17:12:02 +03:00
Unverified
parent 6066ec9767
commit 1db2d55f76
16 changed files with 601 additions and 377 deletions
+66 -4
View File
@@ -155,6 +155,7 @@ export interface SendDMRequest {
salt: string;
iv2: string;
wrappedMk: string;
replyToId?: number;
}
// Responses
@@ -174,22 +175,54 @@ export interface BackupBlob {
blob: string;
}
export interface DmEnvelope {
id: number;
senderId: number;
recipientId: number;
export interface BaseDmEnvelope {
iv: string;
ciphertext: string;
salt: string;
iv2: string;
wrappedMk: string;
recipientId: number;
}
export interface DmEnvelope extends BaseDmEnvelope {
id: number;
senderId: number;
files?: DmFile[];
timestamp: string;
}
export interface DmFile {
name: string;
id: number;
path: string;
}
export interface DmEditedPayload {
id: number;
iv: string;
ciphertext: string;
timestamp: string
}
export interface DmDeletedPayload {
id: number;
senderId: number;
recipientId: number
}
export interface FetchDMResponse {
messages: DmEnvelope[]
}
export interface DmEncryptedJSON {
type: "text",
data: {
content: string;
reply_to_id?: number;
files?: Attachment[];
}
}
// ---------------
// WebSocket types
// ---------------
@@ -231,6 +264,18 @@ export interface WebSocketCredentials {
credentials: string;
}
export interface DMEditWebSocketMessage extends WebSocketMessage {
type: "dmEdit",
data: {
id: number;
iv: string;
ciphertext: string;
iv2: string;
wrappedMk: string;
salt: string;
}
}
export interface Attachment {
path: string;
encrypted: boolean;
@@ -239,6 +284,23 @@ export interface Attachment {
size?: number;
}
// -----------
// Encrypted message JSON (plaintext structure before encryption)
// -----------
export type ChatMessageKind = "text"; // Extendable for future kinds
export interface EncryptedTextMessageData {
content: string;
files?: Attachment[];
reply_to_id?: number | null;
}
export interface EncryptedMessageJson {
type: ChatMessageKind;
data: EncryptedTextMessageData;
}
// -----------
// React types
// -----------