mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
fix: do not mark non-verified group chats as verified when using securejoin
Only mark the chat is verified if 1:1 verified chats are enabled and securejoin targets a 1:1 chat.
This commit is contained in:
@@ -1731,6 +1731,22 @@ async fn apply_group_changes(
|
|||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if mime_parser.get_header(HeaderDef::ChatVerified).is_some() {
|
||||||
|
if let VerifiedEncryption::NotVerified(err) =
|
||||||
|
has_verified_encryption(context, mime_parser, from_id, to_ids, chat.typ).await?
|
||||||
|
{
|
||||||
|
warn!(context, "Verification problem: {err:#}.");
|
||||||
|
let s = format!("{err}. See 'Info' for more details");
|
||||||
|
mime_parser.repl_msg_by_error(&s);
|
||||||
|
}
|
||||||
|
|
||||||
|
if !chat.is_protected() {
|
||||||
|
chat_id
|
||||||
|
.inner_set_protection(context, ProtectionStatus::Protected)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(removed_addr) = mime_parser.get_header(HeaderDef::ChatGroupMemberRemoved) {
|
if let Some(removed_addr) = mime_parser.get_header(HeaderDef::ChatGroupMemberRemoved) {
|
||||||
removed_id = Contact::lookup_id_by_addr(context, removed_addr, Origin::Unknown).await?;
|
removed_id = Contact::lookup_id_by_addr(context, removed_addr, Origin::Unknown).await?;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use percent_encoding::{utf8_percent_encode, AsciiSet, NON_ALPHANUMERIC};
|
|||||||
use crate::aheader::EncryptPreference;
|
use crate::aheader::EncryptPreference;
|
||||||
use crate::chat::{self, Chat, ChatId, ChatIdBlocked, ProtectionStatus};
|
use crate::chat::{self, Chat, ChatId, ChatIdBlocked, ProtectionStatus};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::constants::Blocked;
|
use crate::constants::{Blocked, Chattype};
|
||||||
use crate::contact::{Contact, ContactId, Origin, VerifiedStatus};
|
use crate::contact::{Contact, ContactId, Origin, VerifiedStatus};
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::e2ee::ensure_secret_key_exists;
|
use crate::e2ee::ensure_secret_key_exists;
|
||||||
@@ -701,6 +701,12 @@ async fn secure_connection_established(
|
|||||||
let contact = Contact::get_by_id(context, contact_id).await?;
|
let contact = Contact::get_by_id(context, contact_id).await?;
|
||||||
let msg = stock_str::contact_verified(context, &contact).await;
|
let msg = stock_str::contact_verified(context, &contact).await;
|
||||||
chat::add_info_msg(context, chat_id, &msg, time()).await?;
|
chat::add_info_msg(context, chat_id, &msg, time()).await?;
|
||||||
|
if context
|
||||||
|
.get_config_bool(Config::VerifiedOneOnOneChats)
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
let chat = Chat::load_from_db(context, chat_id).await?;
|
||||||
|
if chat.typ == Chattype::Single {
|
||||||
chat_id
|
chat_id
|
||||||
.set_protection(
|
.set_protection(
|
||||||
context,
|
context,
|
||||||
@@ -709,6 +715,8 @@ 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(())
|
||||||
}
|
}
|
||||||
@@ -786,7 +794,6 @@ mod tests {
|
|||||||
use crate::chat;
|
use crate::chat;
|
||||||
use crate::chat::ProtectionStatus;
|
use crate::chat::ProtectionStatus;
|
||||||
use crate::chatlist::Chatlist;
|
use crate::chatlist::Chatlist;
|
||||||
use crate::constants::Chattype;
|
|
||||||
use crate::contact::ContactAddress;
|
use crate::contact::ContactAddress;
|
||||||
use crate::contact::VerifiedStatus;
|
use crate::contact::VerifiedStatus;
|
||||||
use crate::peerstate::Peerstate;
|
use crate::peerstate::Peerstate;
|
||||||
@@ -801,6 +808,14 @@ mod tests {
|
|||||||
let mut tcm = TestContextManager::new();
|
let mut tcm = TestContextManager::new();
|
||||||
let alice = tcm.alice().await;
|
let alice = tcm.alice().await;
|
||||||
let bob = tcm.bob().await;
|
let bob = tcm.bob().await;
|
||||||
|
alice
|
||||||
|
.set_config(Config::VerifiedOneOnOneChats, Some("1"))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
bob.set_config(Config::VerifiedOneOnOneChats, Some("1"))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Chatlist::try_load(&alice, 0, None, None)
|
Chatlist::try_load(&alice, 0, None, None)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ 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;
|
||||||
@@ -222,6 +223,12 @@ impl BobState {
|
|||||||
let msg = stock_str::contact_verified(context, &contact).await;
|
let msg = stock_str::contact_verified(context, &contact).await;
|
||||||
let chat_id = self.joining_chat_id(context).await?;
|
let chat_id = self.joining_chat_id(context).await?;
|
||||||
chat::add_info_msg(context, chat_id, &msg, time()).await?;
|
chat::add_info_msg(context, chat_id, &msg, time()).await?;
|
||||||
|
|
||||||
|
if context
|
||||||
|
.get_config_bool(Config::VerifiedOneOnOneChats)
|
||||||
|
.await?
|
||||||
|
&& chat_id == self.alice_chat()
|
||||||
|
{
|
||||||
chat_id
|
chat_id
|
||||||
.set_protection(
|
.set_protection(
|
||||||
context,
|
context,
|
||||||
@@ -230,6 +237,8 @@ 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(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user