Small verification fixes (#4317)

* Small performance improvement by not unnecessarily loading the peerstate

* Remove wrong info message "{contact} verified" when scanning a QR code with just an email

I think that this was a bug in the original C code and then slipped
through two refactorings.
This commit is contained in:
Hocuri
2023-04-13 18:14:23 +02:00
committed by GitHub
parent 619b849ce7
commit 28fd27476f
3 changed files with 5 additions and 13 deletions

View File

@@ -11,6 +11,8 @@
- maybe_add_time_based_warnings(): Use release date instead of the provider DB update one
- Cleanly terminate deltachat-rpc-server.
Also terminate on ctrl-c.
- Refactorings #4317
### Fixes
- Fix python bindings README documentation on installing the bindings from source.

View File

@@ -1195,9 +1195,7 @@ impl Contact {
if peerstate.verified_key.is_some() {
return Ok(VerifiedStatus::BidirectVerified);
}
}
if let Some(peerstate) = Peerstate::from_addr(context, &self.addr).await? {
} else if let Some(peerstate) = Peerstate::from_addr(context, &self.addr).await? {
if peerstate.verified_key.is_some() {
return Ok(VerifiedStatus::BidirectVerified);
}

View File

@@ -10,7 +10,7 @@ use percent_encoding::percent_decode_str;
use serde::Deserialize;
use self::dclogin_scheme::configure_from_login_qr;
use crate::chat::{self, get_chat_id_by_grpid, ChatIdBlocked};
use crate::chat::{get_chat_id_by_grpid, ChatIdBlocked};
use crate::config::Config;
use crate::constants::Blocked;
use crate::contact::{
@@ -21,7 +21,6 @@ use crate::key::Fingerprint;
use crate::message::Message;
use crate::peerstate::Peerstate;
use crate::socks::Socks5Config;
use crate::tools::time;
use crate::{token, EventType};
const OPENPGP4FPR_SCHEME: &str = "OPENPGP4FPR:"; // yes: uppercase
@@ -435,16 +434,9 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result<Qr> {
Contact::add_or_lookup(context, &name, peerstate_addr, Origin::UnhandledQrScan)
.await
.context("add_or_lookup")?;
let chat = ChatIdBlocked::get_for_contact(context, contact_id, Blocked::Request)
ChatIdBlocked::get_for_contact(context, contact_id, Blocked::Request)
.await
.context("Failed to create (new) chat for contact")?;
chat::add_info_msg(
context,
chat.id,
&format!("{} verified.", peerstate.addr),
time(),
)
.await?;
Ok(Qr::FprOk { contact_id })
} else {
let contact_id = Contact::lookup_id_by_addr(context, &addr, Origin::Unknown)