Skip to content

feat: Allow leaving a 'Contact Request' channel/group #7007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2908,7 +2908,11 @@ async fn prepare_send_msg(
CantSendReason::ProtectionBroken | CantSendReason::ContactRequest => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe split this into separate branches to not mix different cases? ProtectionBroken isn't related to leaving groups/broadcasts here

// Allow securejoin messages, they are supposed to repair the verification.
// If the chat is a contact request, let the user accept it later.
msg.param.get_cmd() == SystemMessage::SecurejoinMessage
// And allow leaving a contact request chat.
matches!(
msg.param.get_cmd(),
SystemMessage::SecurejoinMessage | SystemMessage::MemberRemovedFromGroup
)
}
// Allow to send "Member removed" messages so we can leave the group/broadcast.
// Necessary checks should be made anyway before removing contact
Expand Down
2 changes: 0 additions & 2 deletions src/chat/chat_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,6 @@ async fn test_leave_group() -> Result<()> {

tcm.section("Bob leaves the group.");
let bob_chat_id = bob_msg.chat_id;
bob_chat_id.accept(&bob).await?;
remove_contact_from_chat(&bob, bob_chat_id, ContactId::SELF).await?;

let leave_msg = bob.pop_sent_msg().await;
Expand Down Expand Up @@ -2963,7 +2962,6 @@ async fn test_leave_broadcast() -> Result<()> {

tcm.section("Bob leaves the broadcast channel.");
let bob_chat_id = bob_msg.chat_id;
bob_chat_id.accept(bob).await?;
remove_contact_from_chat(bob, bob_chat_id, ContactId::SELF).await?;

let leave_msg = bob.pop_sent_msg().await;
Expand Down
Loading