mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-05-02 11:32:35 +02:00
fix(dm): persist delivery_status='delivered' on ACK receipt
DM delivery status was lost when switching conversations because _confirm_delivery() only stored the ACK record and emitted a socket event, but never set delivery_status='delivered' in direct_messages. During retries, each attempt generates a new ACK code. The DM record stores the initial expected_ack, but the actual ACK may arrive for a later retry's code. The ACK lookup by expected_ack then fails to match. Now _confirm_delivery() also sets delivery_status='delivered', and message loading checks this DB field first (like it already did for 'failed'), so delivery persists across page navigations. Also fixed 213 existing DMs on server via data migration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1669,6 +1669,9 @@ class DeviceManager:
|
||||
dm_id=dm_id,
|
||||
)
|
||||
|
||||
# Mark delivery_status so reloading messages from DB shows delivered
|
||||
self.db.update_dm_delivery_status(dm_id, 'delivered')
|
||||
|
||||
logger.info(f"DM delivery confirmed: dm_id={dm_id}, ack={ack_code}")
|
||||
|
||||
if self.socketio:
|
||||
|
||||
@@ -2032,7 +2032,16 @@ def get_dm_messages():
|
||||
elif msg['direction'] == 'outgoing' and msg.get('recipient'):
|
||||
display_name = msg['recipient']
|
||||
|
||||
# Merge delivery status from ACK tracking
|
||||
# Set delivery status from DB field (covers both delivered and failed)
|
||||
for msg in messages:
|
||||
if msg.get('direction') == 'outgoing':
|
||||
ds = msg.get('delivery_status')
|
||||
if ds == 'delivered':
|
||||
msg['status'] = 'delivered'
|
||||
elif ds == 'failed':
|
||||
msg['status'] = 'failed'
|
||||
|
||||
# Merge additional delivery info from ACK tracking
|
||||
ack_codes = [msg['expected_ack'] for msg in messages
|
||||
if msg.get('direction') == 'outgoing' and msg.get('expected_ack')]
|
||||
if ack_codes:
|
||||
@@ -2049,12 +2058,6 @@ def get_dm_messages():
|
||||
except Exception as e:
|
||||
logger.debug(f"ACK status fetch failed (non-critical): {e}")
|
||||
|
||||
# Set failed status for messages without ACK but marked failed in DB
|
||||
for msg in messages:
|
||||
if msg.get('direction') == 'outgoing' and msg.get('status') != 'delivered':
|
||||
if msg.get('delivery_status') == 'failed':
|
||||
msg['status'] = 'failed'
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'conversation_id': conversation_id,
|
||||
|
||||
Reference in New Issue
Block a user