From 94f1bd98de455788e5595a5b7c9d7bef521f0c78 Mon Sep 17 00:00:00 2001 From: MarekWo Date: Sat, 7 Mar 2026 07:26:24 +0100 Subject: [PATCH] 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 --- app/device_manager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/device_manager.py b/app/device_manager.py index 1018cd1..9afc2bb 100644 --- a/app/device_manager.py +++ b/app/device_manager.py @@ -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())