fix: Update verifier_id if it's "unknown" and new verifier has known verifier

Now that the previous commit avoids creating incorrect reverse verification chains, we can do
this. Sure, existing users' dbs aready have verification chains ending with "unknown" roots, but at
least for new users updating `verifier_id` to a known verifier makes sense.
This commit is contained in:
iequidoo
2025-08-29 15:42:17 -03:00
committed by iequidoo
parent 5da6976bf9
commit e6ab1e3df5

View File

@@ -1961,7 +1961,7 @@ pub(crate) async fn mark_contact_id_as_verified(
verifier_id,
"Contact cannot be verified by self",
);
let update = verifier_id == Some(ContactId::SELF);
let by_self = verifier_id == Some(ContactId::SELF);
let mut verifier_id = verifier_id.unwrap_or(contact_id);
context
.sql
@@ -2000,8 +2000,8 @@ pub(crate) async fn mark_contact_id_as_verified(
}
transaction.execute(
"UPDATE contacts SET verifier=?1
WHERE id=?2 AND (verifier=0 OR ?3)",
(verifier_id, contact_id, update),
WHERE id=?2 AND (verifier=0 OR verifier=id OR ?3)",
(verifier_id, contact_id, by_self),
)?;
Ok(())
})