fix(app): ping the relay, retry stuck messages, drop duplicates

A message sent into a dead socket ended up as failed — attachments even
stayed on "sending" forever — and only the user could send it again by
hand. Mobile NAT drops idle TCP silently, so neither side knew.

- pingInterval on the WebSocket, so the client notices a dead link itself
- outbox: after every reconnect, stuck messages are re-sent (batch of 30,
  up to a day old); permanent errors are not retried
- sendAttachment gained the try/catch it was missing, otherwise the
  attachment never reached the outbox
- de-duplicate by message id: a retry re-sends the SAME message, which
  would otherwise show up twice on the other side
This commit is contained in:
Julius Joska
2026-08-13 12:23:24 +02:00
parent b82f50f888
commit 9985b79aa6
5 changed files with 259 additions and 25 deletions
+6 -2
View File
@@ -442,11 +442,15 @@ class SecureStorageService {
);
}
Future<void> addMessage(String contactId, Message message) async {
/// Přidá zprávu do konverzace. Vrací false, když už tam zpráva s tímhle id
/// je (opakované doručení) — volající pak přeskočí navazující kroky jako
/// doručenku nebo stahování přílohy.
Future<bool> addMessage(String contactId, Message message) async {
var conv = await loadConversation(contactId);
conv ??= Conversation(contactId: contactId);
conv.addMessage(message);
if (!conv.addMessage(message)) return false;
await saveConversation(conv);
return true;
}
/// Založí prázdnou konverzaci, pokud ještě není (nová skupina musí být