mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-03-28 17:42:45 +01:00
fix(v2): Fix echo enrichment bug + add analyzer URL to channel messages
Bug: echo enrichment at api.py:384 used leaked `row` variable from previous loop — all messages got echo data from the LAST DB row. Fix: include pkt_payload in message dict during conversion loop, then enrich each message with its own echo data and analyzer URL. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -364,7 +364,8 @@ def get_messages():
|
||||
# Convert DB rows to frontend-compatible format
|
||||
messages = []
|
||||
for row in db_messages:
|
||||
messages.append({
|
||||
pkt_payload = row.get('pkt_payload')
|
||||
msg = {
|
||||
'sender': row.get('sender', ''),
|
||||
'content': row.get('content', ''),
|
||||
'timestamp': row.get('timestamp', 0),
|
||||
@@ -376,16 +377,17 @@ def get_messages():
|
||||
'sender_timestamp': row.get('sender_timestamp'),
|
||||
'txt_type': row.get('txt_type', 0),
|
||||
'raw_text': row.get('content', ''),
|
||||
})
|
||||
'pkt_payload': pkt_payload,
|
||||
}
|
||||
|
||||
# Enrich with echo data from DB (if available)
|
||||
for msg in messages:
|
||||
if msg.get('is_own'):
|
||||
pkt = row.get('pkt_payload') if row else None
|
||||
if pkt:
|
||||
echoes = db.get_echoes_for_message(pkt)
|
||||
msg['echo_count'] = len(echoes)
|
||||
msg['echo_paths'] = [e.get('path', '') for e in echoes]
|
||||
# Enrich own messages with echo data and analyzer URL
|
||||
if msg['is_own'] and pkt_payload:
|
||||
echoes = db.get_echoes_for_message(pkt_payload)
|
||||
msg['echo_count'] = len(echoes)
|
||||
msg['echo_paths'] = [e.get('path', '') for e in echoes]
|
||||
msg['analyzer_url'] = compute_analyzer_url(pkt_payload)
|
||||
|
||||
messages.append(msg)
|
||||
else:
|
||||
# Fallback to parser for file-based reads
|
||||
messages = parser.read_messages(
|
||||
|
||||
Reference in New Issue
Block a user