mirror of
https://github.com/chatmail/core.git
synced 2026-05-16 21:36:30 +03:00
fix: Don't reverify contacts by SELF on receipt of a message from another device
Also verify not yet verified contacts w/o setting a verifier for them (in the db it's stored as `verifier_id=id` though) because we don't know who verified them for another device.
This commit is contained in:
@@ -1948,16 +1948,21 @@ pub(crate) async fn update_last_seen(
|
||||
}
|
||||
|
||||
/// Marks contact `contact_id` as verified by `verifier_id`.
|
||||
///
|
||||
/// `verifier_id == None` means that the verifier is unknown.
|
||||
pub(crate) async fn mark_contact_id_as_verified(
|
||||
context: &Context,
|
||||
contact_id: ContactId,
|
||||
verifier_id: ContactId,
|
||||
verifier_id: Option<ContactId>,
|
||||
) -> Result<()> {
|
||||
ensure_and_debug_assert_ne!(contact_id, ContactId::SELF,);
|
||||
ensure_and_debug_assert_ne!(
|
||||
contact_id,
|
||||
Some(contact_id),
|
||||
verifier_id,
|
||||
"Contact cannot be verified by self",
|
||||
);
|
||||
let update = verifier_id == Some(ContactId::SELF);
|
||||
let verifier_id = verifier_id.unwrap_or(contact_id);
|
||||
context
|
||||
.sql
|
||||
.transaction(|transaction| {
|
||||
@@ -1983,8 +1988,8 @@ pub(crate) async fn mark_contact_id_as_verified(
|
||||
}
|
||||
transaction.execute(
|
||||
"UPDATE contacts SET verifier=?1
|
||||
WHERE id=?2 AND (verifier=0 OR ?1=?3)",
|
||||
(verifier_id, contact_id, ContactId::SELF),
|
||||
WHERE id=?2 AND (verifier=0 OR ?3)",
|
||||
(verifier_id, contact_id, update),
|
||||
)?;
|
||||
Ok(())
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user