fix: Use unstripped raw_text for pkt_payload computation

The parser's .strip() was removing trailing whitespace from message
text, but the encrypted radio payload includes those trailing spaces.
This caused pkt_payload mismatches for messages ending with spaces
(e.g., "Dzień dobry "). Use original unstripped text for raw_text.

Also add debug logging for unmatched messages to help diagnose
remaining edge cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-02-21 08:09:28 +01:00
parent 28148d32d8
commit 68b2166445
2 changed files with 14 additions and 2 deletions
+3 -2
View File
@@ -37,7 +37,8 @@ def parse_message(line: Dict, allowed_channels: Optional[List[int]] = None) -> O
return None
timestamp = line.get('timestamp', 0)
text = line.get('text', '').strip()
raw_text = line.get('text', '')
text = raw_text.strip()
if not text:
return None
@@ -72,7 +73,7 @@ def parse_message(line: Dict, allowed_channels: Optional[List[int]] = None) -> O
'channel_idx': channel_idx,
'sender_timestamp': line.get('sender_timestamp'),
'txt_type': line.get('txt_type', 0),
'raw_text': text
'raw_text': raw_text
}
+11
View File
@@ -378,6 +378,7 @@ def get_messages():
for msg in messages:
if not msg.get('is_own') and msg.get('sender_timestamp') and msg.get('channel_idx') in channel_secrets:
secret = channel_secrets[msg['channel_idx']]
matched = False
for attempt in range(4):
try:
payload = compute_pkt_payload(
@@ -390,7 +391,17 @@ def get_messages():
entry = incoming_by_payload[payload]
msg['paths'] = entry.get('paths', [])
msg['analyzer_url'] = compute_analyzer_url(payload)
matched = True
break
if not matched and incoming_by_payload:
raw = msg.get('raw_text', '')
logger.debug(
f"Echo mismatch: ts={msg.get('sender_timestamp')} "
f"ch={msg.get('channel_idx')} "
f"text_bytes={len(raw.encode('utf-8'))} "
f"computed_payload={payload[:16]}... "
f"text_preview={raw[:40]!r}"
)
except Exception as e:
logger.debug(f"Echo data fetch failed (non-critical): {e}")