mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-08-10 18:52:55 +02:00
fix(dm): persist delivery_path_hash_size so reloaded bubbles render multi-byte routes
Live dm_delivered_info already carried the correct hash_size, but the DB row only kept delivery_path. After a reload the API filled in path_hash_size from the incoming path_len column (NULL for outgoing DMs → default 1), so 2-byte routes were re-rendered as single-byte hops. Added a delivery_path_hash_size column (auto-migrated, defaults to 1) that update_dm_delivery_info now stores alongside the delivery path, populated from the same hash_size already known by each delivery path (retry ctx, PATH event, delayed contact backfill). /api/dm/messages returns the new field; dm.js prefers it over path_hash_size when rendering the Route line, falling back to the old field for legacy rows.
This commit is contained in:
+7
-4
@@ -51,6 +51,7 @@ class Database:
|
||||
('delivery_attempt', 'INTEGER'),
|
||||
('delivery_max_attempts', 'INTEGER'),
|
||||
('delivery_path', 'TEXT'),
|
||||
('delivery_path_hash_size', 'INTEGER DEFAULT 1'),
|
||||
]:
|
||||
if col not in dm_columns:
|
||||
conn.execute(f"ALTER TABLE direct_messages ADD COLUMN {col} {typedef}")
|
||||
@@ -788,13 +789,15 @@ class Database:
|
||||
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)."""
|
||||
max_attempts: int, path: str,
|
||||
hash_size: int = 1):
|
||||
"""Store successful delivery details (attempt number, path used, hop byte size)."""
|
||||
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))
|
||||
"delivery_max_attempts=?, delivery_path=?, delivery_path_hash_size=? "
|
||||
"WHERE id=?",
|
||||
(attempt, max_attempts, path, hash_size, dm_id))
|
||||
|
||||
def update_dm_delivery_status(self, dm_id: int, status: str):
|
||||
"""Mark message delivery as failed."""
|
||||
|
||||
Reference in New Issue
Block a user