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:
@@ -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}`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user