feat: Contact::lookup_id_by_addr_ex: Prefer returning key-contact

If an address-contact and a key-contact were seen at exactly the same time, that doesn't necessarily
mean that it's a random event, it might occur because some code updates contacts this way in some
scenario. While this is unlikely, prefer to look up the key-contact.
This commit is contained in:
iequidoo
2025-08-04 19:09:00 -03:00
committed by iequidoo
parent b431206ede
commit f5f4026dbb
3 changed files with 62 additions and 24 deletions

View File

@@ -808,7 +808,7 @@ impl Contact {
"SELECT id FROM contacts
WHERE addr=?1 COLLATE NOCASE
AND id>?2 AND origin>=?3 AND (? OR blocked=?)
ORDER BY last_seen DESC LIMIT 1",
ORDER BY last_seen DESC, fingerprint DESC LIMIT 1",
(
&addr_normalized,
ContactId::LAST_SPECIAL,