Add V2 chat protocol support and improve error handling

Introduces support for V2 encrypted chat envelopes in the swarm inbox route, allowing storage and processing of new message formats. Enhances error handling and logging in both chat send and encryption hooks, including detection of remote nodes that do not support the V2 protocol and providing clearer error messages for users and developers.
This commit is contained in:
Christopher
2026-01-27 21:25:51 -08:00
parent e92c747a5b
commit dd87d51fa6
3 changed files with 76 additions and 4 deletions
+8 -2
View File
@@ -412,8 +412,14 @@ export function useChatEncryption() {
});
if (!sendRes.ok) {
const errorData = await sendRes.json().catch(() => ({ error: 'Unknown error' }));
console.error('[Chat] Send failed:', errorData);
const errorText = await sendRes.text();
let errorData;
try {
errorData = JSON.parse(errorText);
} catch {
errorData = { error: errorText };
}
console.error('[Chat] Send failed:', sendRes.status, errorData);
throw new Error(`Failed to send message: ${errorData.error || sendRes.statusText}`);
}