From 34b6e9b1ec4d46648447c9719870ad81d6137069 Mon Sep 17 00:00:00 2001 From: MarekWo Date: Sat, 7 Mar 2026 13:37:51 +0100 Subject: [PATCH] fix(contacts): fallback add to mc.contacts after approve ensure_contacts(follow=True) may not return the just-added contact. Add manual fallback to mc.contacts so /api/contacts/detailed and send_dm can find it immediately. Co-Authored-By: Claude Opus 4.6 --- app/device_manager.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/device_manager.py b/app/device_manager.py index 3d4ebab..30ee951 100644 --- a/app/device_manager.py +++ b/app/device_manager.py @@ -1180,6 +1180,14 @@ class DeviceManager: # Refresh mc.contacts so send_dm can find the new contact self.execute(self.mc.ensure_contacts(follow=True)) + # Fallback: if ensure_contacts didn't pick up the new contact, + # add it manually to mc.contacts (firmware may need time) + if pubkey not in (self.mc.contacts or {}): + if self.mc.contacts is None: + self.mc.contacts = {} + self.mc.contacts[pubkey] = contact + logger.info(f"Manually added {pubkey[:12]}... to mc.contacts") + last_adv = contact.get('last_advert') last_advert_val = ( str(int(last_adv))