mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-08-07 17:22:57 +02:00
fix(dm): clear error when contact not on device, log error_code detail
Device firmware requires contacts in its table to send DMs. Passing a raw pubkey string results in error_code=2. Show actionable error message instead of generic "Device error". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -827,14 +827,15 @@ class DeviceManager:
|
||||
return {'success': False, 'error': 'Device not connected'}
|
||||
|
||||
try:
|
||||
# Find contact dict from mc.contacts (used for retry/path info)
|
||||
# send_msg() also accepts a hex pubkey string directly
|
||||
# Find contact in device's contact table
|
||||
contact = self.mc.contacts.get(recipient_pubkey)
|
||||
if not contact:
|
||||
contact = self.mc.get_contact_by_key_prefix(recipient_pubkey)
|
||||
if not contact:
|
||||
# Use pubkey string directly — meshcore lib handles it
|
||||
contact = recipient_pubkey
|
||||
# Contact must exist on device to send DM
|
||||
return {'success': False,
|
||||
'error': f'Contact not on device. '
|
||||
f'Re-add {recipient_pubkey[:12]}... via Contacts page.'}
|
||||
|
||||
# Generate timestamp once — same for all retries (enables receiver dedup)
|
||||
timestamp = int(time.time())
|
||||
|
||||
Reference in New Issue
Block a user