feat(dm): add real-time retry status and persistent delivery info

Show retry progress in DM message bubble via WebSocket:
- "attempt X/Y" counter updates in real-time during retries
- Failed icon (✗) when all retries exhausted
- Delivery info persisted in DB (attempt number, path used)

Backend: emit dm_retry_status/dm_retry_failed socket events,
store delivery_attempt/delivery_path in direct_messages table.
Frontend: socket listeners update status icon and counter,
delivered tooltip shows attempt info and path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-03-28 12:25:35 +01:00
parent d2e019fa0e
commit 7dbbba57b9
5 changed files with 190 additions and 67 deletions
+28
View File
@@ -44,6 +44,18 @@ class Database:
conn.execute("ALTER TABLE contacts ADD COLUMN no_auto_flood INTEGER DEFAULT 0")
logger.info("Migration: added contacts.no_auto_flood column")
# Add delivery tracking columns to direct_messages
dm_columns = {r[1] for r in conn.execute("PRAGMA table_info(direct_messages)").fetchall()}
for col, typedef in [
('delivery_status', 'TEXT'),
('delivery_attempt', 'INTEGER'),
('delivery_max_attempts', 'INTEGER'),
('delivery_path', 'TEXT'),
]:
if col not in dm_columns:
conn.execute(f"ALTER TABLE direct_messages ADD COLUMN {col} {typedef}")
logger.info(f"Migration: added direct_messages.{col} column")
@contextmanager
def _connect(self):
"""Yield a connection with auto-commit/rollback."""
@@ -660,6 +672,22 @@ class Database:
).fetchone()
return dict(row) if row else None
def update_dm_delivery_info(self, dm_id: int, attempt: int,
max_attempts: int, path: str):
"""Store successful delivery details (attempt number, path used)."""
with self._connect() as conn:
conn.execute(
"UPDATE direct_messages SET delivery_attempt=?, "
"delivery_max_attempts=?, delivery_path=? WHERE id=?",
(attempt, max_attempts, path, dm_id))
def update_dm_delivery_status(self, dm_id: int, status: str):
"""Mark message delivery as failed."""
with self._connect() as conn:
conn.execute(
"UPDATE direct_messages SET delivery_status=? WHERE id=?",
(status, dm_id))
def relink_orphaned_dms(self, public_key: str, name: str = '') -> int:
"""Re-link DMs with NULL contact_pubkey back to this contact.