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 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-03-07 13:37:51 +01:00
parent 6c34ce85d8
commit 34b6e9b1ec
+8
View File
@@ -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))