fix: Securejoin: Mark 1:1s as protected regardless of the Config::VerifiedOneOnOneChats

As per the comment in `receive_imf.rs`, `chat.protected` must be maintained regardless of the
`Config::VerifiedOneOnOneChats`. The only thing that mustn't be done if `VerifiedOneOnOneChats` is
unset (i.e. for non-supporting UIs) is marking chats as "protection broken" because this needs
showing the corresponding dialog to a user.
This commit is contained in:
iequidoo
2023-12-16 16:16:42 -03:00
committed by iequidoo
parent 78affb766e
commit 35bd56ffea
3 changed files with 31 additions and 46 deletions

View File

@@ -2454,7 +2454,6 @@ async fn mark_recipients_as_verified(
peerstate.set_verified(PeerstateKeyType::GossipKey, fp, verifier_addr)?; peerstate.set_verified(PeerstateKeyType::GossipKey, fp, verifier_addr)?;
peerstate.save_to_db(&context.sql).await?; peerstate.save_to_db(&context.sql).await?;
if !is_verified {
let (to_contact_id, _) = Contact::add_or_lookup( let (to_contact_id, _) = Contact::add_or_lookup(
context, context,
"", "",
@@ -2469,7 +2468,6 @@ async fn mark_recipients_as_verified(
) )
.await?; .await?;
} }
}
} else { } else {
// The contact already has a verified key. // The contact already has a verified key.
// Store gossiped key as the secondary verified key. // Store gossiped key as the secondary verified key.

View File

@@ -689,10 +689,6 @@ async fn secure_connection_established(
chat_id: ChatId, chat_id: ChatId,
timestamp: i64, timestamp: i64,
) -> Result<()> { ) -> Result<()> {
if context
.get_config_bool(Config::VerifiedOneOnOneChats)
.await?
{
let private_chat_id = ChatIdBlocked::get_for_contact(context, contact_id, Blocked::Yes) let private_chat_id = ChatIdBlocked::get_for_contact(context, contact_id, Blocked::Yes)
.await? .await?
.id; .id;
@@ -704,7 +700,6 @@ async fn secure_connection_established(
Some(contact_id), Some(contact_id),
) )
.await?; .await?;
}
context.emit_event(EventType::ChatModified(chat_id)); context.emit_event(EventType::ChatModified(chat_id));
Ok(()) Ok(())
} }

View File

@@ -9,7 +9,6 @@ use super::bobstate::{BobHandshakeStage, BobState};
use super::qrinvite::QrInvite; use super::qrinvite::QrInvite;
use super::HandshakeMessage; use super::HandshakeMessage;
use crate::chat::{is_contact_in_chat, ChatId, ProtectionStatus}; use crate::chat::{is_contact_in_chat, ChatId, ProtectionStatus};
use crate::config::Config;
use crate::constants::{Blocked, Chattype}; use crate::constants::{Blocked, Chattype};
use crate::contact::Contact; use crate::contact::Contact;
use crate::context::Context; use crate::context::Context;
@@ -225,11 +224,6 @@ impl BobState {
async fn notify_peer_verified(&self, context: &Context, timestamp: i64) -> Result<()> { async fn notify_peer_verified(&self, context: &Context, timestamp: i64) -> Result<()> {
let contact = Contact::get_by_id(context, self.invite().contact_id()).await?; let contact = Contact::get_by_id(context, self.invite().contact_id()).await?;
let chat_id = self.joining_chat_id(context).await?; let chat_id = self.joining_chat_id(context).await?;
if context
.get_config_bool(Config::VerifiedOneOnOneChats)
.await?
{
self.alice_chat() self.alice_chat()
.set_protection( .set_protection(
context, context,
@@ -238,8 +232,6 @@ impl BobState {
Some(contact.id), Some(contact.id),
) )
.await?; .await?;
}
context.emit_event(EventType::ChatModified(chat_id)); context.emit_event(EventType::ChatModified(chat_id));
Ok(()) Ok(())
} }