Skip to content

Commit 87a7982

Browse files
committed
iequidoo's and link2xt's review
1 parent 953dc3f commit 87a7982

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/chat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,7 +2855,7 @@ async fn prepare_send_msg(
28552855
// If the chat is a contact request, let the user accept it later.
28562856
msg.param.get_cmd() == SystemMessage::SecurejoinMessage
28572857
}
2858-
// Allow to send "Member removed" messages so we can leave the group.
2858+
// Allow to send "Member removed" messages so we can leave the group/broadcast.
28592859
// Necessary checks should be made anyway before removing contact
28602860
// from the chat.
28612861
CantSendReason::NotAMember | CantSendReason::InBroadcast => {
@@ -4117,7 +4117,7 @@ async fn send_member_removal_msg(
41174117
msg.param.set_cmd(SystemMessage::MemberRemovedFromGroup);
41184118
msg.param.set(Param::Arg, addr.to_lowercase());
41194119
msg.param
4120-
.set(Param::ContactAddedRemoved, contact_id.to_u32() as i32);
4120+
.set(Param::ContactAddedRemoved, contact_id.to_u32());
41214121

41224122
send_msg(context, chat_id, &mut msg).await
41234123
}

src/chat/chat_tests.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,10 @@ async fn test_member_add_remove() -> Result<()> {
373373
// Alice leaves the chat.
374374
remove_contact_from_chat(&alice, alice_chat_id, ContactId::SELF).await?;
375375
let sent = alice.pop_sent_msg().await;
376-
assert_eq!(sent.load_from_db().await.get_text(), "You left.");
376+
assert_eq!(
377+
sent.load_from_db().await.get_text(),
378+
stock_str::msg_group_left_local(&alice, ContactId::SELF).await
379+
);
377380

378381
Ok(())
379382
}
@@ -2892,19 +2895,19 @@ async fn test_block_broadcast() -> Result<()> {
28922895
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
28932896
async fn test_leave_broadcast() -> Result<()> {
28942897
let mut tcm = TestContextManager::new();
2895-
let alice = tcm.alice().await;
2896-
let bob = tcm.bob().await;
2898+
let alice = &tcm.alice().await;
2899+
let bob = &tcm.bob().await;
28972900

28982901
tcm.section("Alice creates broadcast channel with Bob.");
2899-
let alice_chat_id = create_broadcast(&alice, "foo".to_string()).await?;
2900-
let bob_contact = alice.add_or_lookup_contact(&bob).await.id;
2901-
add_contact_to_chat(&alice, alice_chat_id, bob_contact).await?;
2902+
let alice_chat_id = create_broadcast(alice, "foo".to_string()).await?;
2903+
let bob_contact = alice.add_or_lookup_contact(bob).await.id;
2904+
add_contact_to_chat(alice, alice_chat_id, bob_contact).await?;
29022905

29032906
tcm.section("Alice sends first message to broadcast.");
29042907
let sent_msg = alice.send_text(alice_chat_id, "Hello!").await;
29052908
let bob_msg = bob.recv_msg(&sent_msg).await;
29062909

2907-
assert_eq!(get_chat_contacts(&alice, alice_chat_id).await?.len(), 1);
2910+
assert_eq!(get_chat_contacts(alice, alice_chat_id).await?.len(), 1);
29082911

29092912
// Clear events so that we can later check
29102913
// that the 'Broadcast channel left' message didn't trigger IncomingMsg:
@@ -2915,13 +2918,13 @@ async fn test_leave_broadcast() -> Result<()> {
29152918

29162919
tcm.section("Bob leaves the broadcast channel.");
29172920
let bob_chat_id = bob_msg.chat_id;
2918-
bob_chat_id.accept(&bob).await?;
2919-
remove_contact_from_chat(&bob, bob_chat_id, ContactId::SELF).await?;
2921+
bob_chat_id.accept(bob).await?;
2922+
remove_contact_from_chat(bob, bob_chat_id, ContactId::SELF).await?;
29202923

29212924
let leave_msg = bob.pop_sent_msg().await;
29222925
alice.recv_msg_trash(&leave_msg).await;
29232926

2924-
assert_eq!(get_chat_contacts(&alice, alice_chat_id).await?.len(), 0);
2927+
assert_eq!(get_chat_contacts(alice, alice_chat_id).await?.len(), 0);
29252928

29262929
alice.emit_event(EventType::Test);
29272930
alice

0 commit comments

Comments
 (0)