mirror of
https://github.com/chatmail/core.git
synced 2026-04-20 15:06:30 +03:00
fix: do not block new group chats if 1:1 chat is blocked
1:1 chat may be blocked while the contact is not if 1:1 chat was created as a result of scanning a verified group join QR code with the contact as the inviter. In this case 1:1 chat is blocked to hide it while the contact is unblocked.
This commit is contained in:
@@ -1679,6 +1679,36 @@ def test_qr_join_chat(acfactory, lp):
|
|||||||
ac1._evtracker.wait_securejoin_inviter_progress(1000)
|
ac1._evtracker.wait_securejoin_inviter_progress(1000)
|
||||||
|
|
||||||
|
|
||||||
|
def test_qr_new_group_unblocked(acfactory, lp):
|
||||||
|
"""Regression test for a bug intoduced in core v1.113.0.
|
||||||
|
ac2 scans a verified group QR code created by ac1.
|
||||||
|
This results in creation of a blocked 1:1 chat with ac1 on ac2,
|
||||||
|
but ac1 contact is not blocked on ac2.
|
||||||
|
Then ac1 creates a group, adds ac2 there and promotes it by sending a message.
|
||||||
|
ac2 should receive a message and create a contact request for the group.
|
||||||
|
Due to a bug previously ac2 created a blocked group.
|
||||||
|
"""
|
||||||
|
|
||||||
|
ac1, ac2 = acfactory.get_online_accounts(2)
|
||||||
|
ac1_chat = ac1.create_group_chat("Group for joining", verified=True)
|
||||||
|
qr = ac1_chat.get_join_qr()
|
||||||
|
ac2.qr_join_chat(qr)
|
||||||
|
|
||||||
|
ac1._evtracker.wait_securejoin_inviter_progress(1000)
|
||||||
|
|
||||||
|
ac1_new_chat = ac1.create_group_chat("Another group")
|
||||||
|
ac1_new_chat.add_contact(ac2)
|
||||||
|
ac1_new_chat.send_text("Hello!")
|
||||||
|
|
||||||
|
# Receive "Member added" message.
|
||||||
|
ac2._evtracker.wait_next_incoming_message()
|
||||||
|
|
||||||
|
# Receive "Hello!" message.
|
||||||
|
ac2_msg = ac2._evtracker.wait_next_incoming_message()
|
||||||
|
assert ac2_msg.text == "Hello!"
|
||||||
|
assert ac2_msg.chat.is_contact_request()
|
||||||
|
|
||||||
|
|
||||||
def test_qr_email_capitalization(acfactory, lp):
|
def test_qr_email_capitalization(acfactory, lp):
|
||||||
"""Regression test for a bug
|
"""Regression test for a bug
|
||||||
that resulted in failure to propagate verification via gossip in a verified group
|
that resulted in failure to propagate verification via gossip in a verified group
|
||||||
|
|||||||
@@ -546,19 +546,30 @@ async fn add_parts(
|
|||||||
// signals whether the current user is a bot
|
// signals whether the current user is a bot
|
||||||
let is_bot = context.get_config_bool(Config::Bot).await?;
|
let is_bot = context.get_config_bool(Config::Bot).await?;
|
||||||
|
|
||||||
let create_blocked = match test_normal_chat {
|
let create_blocked_default = if is_bot {
|
||||||
Some(ChatIdBlocked {
|
Blocked::Not
|
||||||
id: _,
|
} else {
|
||||||
blocked: Blocked::Request,
|
Blocked::Request
|
||||||
}) if is_bot => Blocked::Not,
|
};
|
||||||
Some(ChatIdBlocked { id: _, blocked }) => blocked,
|
let create_blocked = if let Some(ChatIdBlocked { id: _, blocked }) = test_normal_chat {
|
||||||
None => {
|
match blocked {
|
||||||
if is_bot {
|
Blocked::Request => create_blocked_default,
|
||||||
Blocked::Not
|
Blocked::Not => Blocked::Not,
|
||||||
} else {
|
Blocked::Yes => {
|
||||||
Blocked::Request
|
if Contact::is_blocked_load(context, from_id).await? {
|
||||||
|
// User has blocked the contact.
|
||||||
|
// Block the group contact created as well.
|
||||||
|
Blocked::Yes
|
||||||
|
} else {
|
||||||
|
// 1:1 chat is blocked, but the contact is not.
|
||||||
|
// This happens when 1:1 chat is hidden
|
||||||
|
// during scanning of a group invitation code.
|
||||||
|
Blocked::Request
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
create_blocked_default
|
||||||
};
|
};
|
||||||
|
|
||||||
if chat_id.is_none() {
|
if chat_id.is_none() {
|
||||||
|
|||||||
Reference in New Issue
Block a user