Skip to content

Commit 0426baa

Browse files
committed
iequidoo's and link2xt's review
1 parent d626033 commit 0426baa

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
@@ -2905,7 +2905,7 @@ async fn prepare_send_msg(
29052905
// If the chat is a contact request, let the user accept it later.
29062906
msg.param.get_cmd() == SystemMessage::SecurejoinMessage
29072907
}
2908-
// Allow to send "Member removed" messages so we can leave the group.
2908+
// Allow to send "Member removed" messages so we can leave the group/broadcast.
29092909
// Necessary checks should be made anyway before removing contact
29102910
// from the chat.
29112911
CantSendReason::NotAMember | CantSendReason::InBroadcast => {
@@ -4161,7 +4161,7 @@ async fn send_member_removal_msg(
41614161
msg.param.set_cmd(SystemMessage::MemberRemovedFromGroup);
41624162
msg.param.set(Param::Arg, addr.to_lowercase());
41634163
msg.param
4164-
.set(Param::ContactAddedRemoved, contact_id.to_u32() as i32);
4164+
.set(Param::ContactAddedRemoved, contact_id.to_u32());
41654165

41664166
send_msg(context, chat_id, &mut msg).await
41674167
}

src/chat/chat_tests.rs

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

379382
Ok(())
380383
}
@@ -2934,19 +2937,19 @@ async fn test_broadcast_channel_protected_listid() -> Result<()> {
29342937
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
29352938
async fn test_leave_broadcast() -> Result<()> {
29362939
let mut tcm = TestContextManager::new();
2937-
let alice = tcm.alice().await;
2938-
let bob = tcm.bob().await;
2940+
let alice = &tcm.alice().await;
2941+
let bob = &tcm.bob().await;
29392942

29402943
tcm.section("Alice creates broadcast channel with Bob.");
2941-
let alice_chat_id = create_broadcast(&alice, "foo".to_string()).await?;
2942-
let bob_contact = alice.add_or_lookup_contact(&bob).await.id;
2943-
add_contact_to_chat(&alice, alice_chat_id, bob_contact).await?;
2944+
let alice_chat_id = create_broadcast(alice, "foo".to_string()).await?;
2945+
let bob_contact = alice.add_or_lookup_contact(bob).await.id;
2946+
add_contact_to_chat(alice, alice_chat_id, bob_contact).await?;
29442947

29452948
tcm.section("Alice sends first message to broadcast.");
29462949
let sent_msg = alice.send_text(alice_chat_id, "Hello!").await;
29472950
let bob_msg = bob.recv_msg(&sent_msg).await;
29482951

2949-
assert_eq!(get_chat_contacts(&alice, alice_chat_id).await?.len(), 1);
2952+
assert_eq!(get_chat_contacts(alice, alice_chat_id).await?.len(), 1);
29502953

29512954
// Clear events so that we can later check
29522955
// that the 'Broadcast channel left' message didn't trigger IncomingMsg:
@@ -2957,13 +2960,13 @@ async fn test_leave_broadcast() -> Result<()> {
29572960

29582961
tcm.section("Bob leaves the broadcast channel.");
29592962
let bob_chat_id = bob_msg.chat_id;
2960-
bob_chat_id.accept(&bob).await?;
2961-
remove_contact_from_chat(&bob, bob_chat_id, ContactId::SELF).await?;
2963+
bob_chat_id.accept(bob).await?;
2964+
remove_contact_from_chat(bob, bob_chat_id, ContactId::SELF).await?;
29622965

29632966
let leave_msg = bob.pop_sent_msg().await;
29642967
alice.recv_msg_trash(&leave_msg).await;
29652968

2966-
assert_eq!(get_chat_contacts(&alice, alice_chat_id).await?.len(), 0);
2969+
assert_eq!(get_chat_contacts(alice, alice_chat_id).await?.len(), 0);
29672970

29682971
alice.emit_event(EventType::Test);
29692972
alice

0 commit comments

Comments
 (0)