mirror of
https://github.com/chatmail/core.git
synced 2026-05-05 14:26:30 +03:00
non-blocking group QR joins (#2508)
* refactor: cleanup send_handshake_msg() - rename to send_alice_handshake_msg() as used by Alice only - remove dead code from Bob (Bob's code is at BobState::send_handshake_message() since some time) - take a contact_id and not a chat_id; this makes things less confusing when info-messages are put to the final group chat * always directly return chat-id from dc_join_securejoin() * take care not to create a group twice * adapt documentation * add info-msg on group invites; add inviter directly after creation * document existing 'joinqr' command in repl tool * do not create empty one-to-one chats for group-joins * refactor: cleanup fingerprint_equals_sender() - the function takes a contact_id directly now. before it consumes the first contact of a one-to-one chat - which may be easily confused with the group-chat in creation. moreover, the conversion contact_id -> chat_id -> contact_id is unneeded overhead. * show info-messages in destination chat for alice * fingerprint_equals_sender() returns Err on database failure * tweak documentation * clarify what an 'unfinished tasks' task is. * add regression test for create_for_contact_with_blocked() * rename Blocked::Manually to better fitting Blocked::Yes * tweak test_secure_join() and make sure, Alice and Bob have only on chat after a group-join
This commit is contained in:
@@ -633,7 +633,9 @@ async fn add_parts(
|
||||
|
||||
if chat_id.is_none() {
|
||||
// try to create a normal chat
|
||||
let create_blocked = if from_id == to_id {
|
||||
let create_blocked = if *hidden {
|
||||
Blocked::Yes
|
||||
} else if from_id == DC_CONTACT_ID_SELF {
|
||||
Blocked::Not
|
||||
} else {
|
||||
Blocked::Request
|
||||
@@ -798,7 +800,7 @@ async fn add_parts(
|
||||
if chat_id.is_none() && allow_creation {
|
||||
let create_blocked = if !Contact::is_blocked_load(context, to_id).await? {
|
||||
if self_sent && *hidden {
|
||||
Blocked::Manually
|
||||
Blocked::Yes
|
||||
} else {
|
||||
Blocked::Not
|
||||
}
|
||||
@@ -1543,6 +1545,17 @@ async fn create_or_lookup_group(
|
||||
}
|
||||
set_better_msg(mime_parser, &better_msg);
|
||||
|
||||
let create_protected = if mime_parser.get_header(HeaderDef::ChatVerified).is_some() {
|
||||
if let Err(err) = check_verified_properties(context, mime_parser, from_id, to_ids).await {
|
||||
warn!(context, "verification problem: {}", err);
|
||||
let s = format!("{}. See 'Info' for more details", err);
|
||||
mime_parser.repl_msg_by_error(&s);
|
||||
}
|
||||
ProtectionStatus::Protected
|
||||
} else {
|
||||
ProtectionStatus::Unprotected
|
||||
};
|
||||
|
||||
// check if the group does not exist but should be created
|
||||
let group_explicitly_left = chat::is_group_explicitly_left(context, &grpid)
|
||||
.await
|
||||
@@ -1563,18 +1576,6 @@ async fn create_or_lookup_group(
|
||||
|| X_MrAddToGrp.is_some() && addr_cmp(&self_addr, X_MrAddToGrp.as_ref().unwrap()))
|
||||
{
|
||||
// group does not exist but should be created
|
||||
let create_protected = if mime_parser.get_header(HeaderDef::ChatVerified).is_some() {
|
||||
if let Err(err) = check_verified_properties(context, mime_parser, from_id, to_ids).await
|
||||
{
|
||||
warn!(context, "verification problem: {}", err);
|
||||
let s = format!("{}. See 'Info' for more details", err);
|
||||
mime_parser.repl_msg_by_error(&s);
|
||||
}
|
||||
ProtectionStatus::Protected
|
||||
} else {
|
||||
ProtectionStatus::Unprotected
|
||||
};
|
||||
|
||||
if !allow_creation {
|
||||
info!(context, "creating group forbidden by caller");
|
||||
return Ok(None);
|
||||
@@ -1615,6 +1616,16 @@ async fn create_or_lookup_group(
|
||||
// .add_protection_msg(context, ProtectionStatus::Protected, false, 0)
|
||||
// .await?;
|
||||
//}
|
||||
} else if let Some(chat_id) = chat_id {
|
||||
if create_protected == ProtectionStatus::Protected {
|
||||
let chat = Chat::load_from_db(context, chat_id).await?;
|
||||
if !chat.is_protected() {
|
||||
chat_id
|
||||
.inner_set_protection(context, ProtectionStatus::Protected)
|
||||
.await?;
|
||||
recreate_member_list = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// again, check chat_id
|
||||
|
||||
Reference in New Issue
Block a user