fix(dm): don't require contact in mc.contacts to send DM

When the contact is not found in the in-memory mc.contacts dict,
fall back to passing the pubkey hex string directly to send_msg()
which handles it natively. Fixes "Contact not found" error.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-03-07 07:26:24 +01:00
parent 8f31c27360
commit 94f1bd98de
+4 -3
View File
@@ -827,13 +827,14 @@ class DeviceManager:
return {'success': False, 'error': 'Device not connected'}
try:
# Find contact by pubkey
# Find contact dict from mc.contacts (used for retry/path info)
# send_msg() also accepts a hex pubkey string directly
contact = self.mc.contacts.get(recipient_pubkey)
if not contact:
# Try prefix match
contact = self.mc.get_contact_by_key_prefix(recipient_pubkey)
if not contact:
return {'success': False, 'error': f'Contact not found: {recipient_pubkey}'}
# Use pubkey string directly — meshcore lib handles it
contact = recipient_pubkey
# Generate timestamp once — same for all retries (enables receiver dedup)
timestamp = int(time.time())