mirror of
https://github.com/chatmail/core.git
synced 2026-04-18 05:56:31 +03:00
Fix #1791 and show all group messages if the user already is in the group, even if the sender is blocked Also fix a comment Co-authored-by: link2xt <ilabdsf@gmail.com>
This commit is contained in:
@@ -1402,6 +1402,46 @@ class TestOnlineAccount:
|
||||
assert ev.action == "removed"
|
||||
assert ev.message.get_sender_contact().addr == ac1_addr
|
||||
|
||||
def test_system_group_msg_from_blocked_user(self, acfactory, lp):
|
||||
"""
|
||||
Tests that a blocked user removes you from a group.
|
||||
The message has to be fetched even though the user is blocked
|
||||
to avoid inconsistent group state.
|
||||
Also tests blocking in general.
|
||||
"""
|
||||
lp.sec("Create a group chat with ac1 and ac2")
|
||||
(ac1, ac2) = acfactory.get_two_online_accounts()
|
||||
acfactory.introduce_each_other((ac1, ac2))
|
||||
chat_on_ac1 = ac1.create_group_chat("title", contacts=[ac2])
|
||||
chat_on_ac1.send_text("First group message")
|
||||
chat_on_ac2 = ac2._evtracker.wait_next_incoming_message().chat
|
||||
|
||||
lp.sec("ac1 blocks ac2")
|
||||
contact = ac1.create_contact(ac2)
|
||||
contact.set_blocked()
|
||||
assert contact.is_blocked()
|
||||
|
||||
lp.sec("ac2 sends a message to ac1 that does not arrive because it is blocked")
|
||||
ac2.create_chat(ac1).send_text("This will not arrive!")
|
||||
|
||||
lp.sec("ac2 sends a group message to ac1 that arrives")
|
||||
# Groups would be hardly usable otherwise: If you have blocked some
|
||||
# users, they write messages and you only see replies to them without context
|
||||
chat_on_ac2.send_text("This will arrive")
|
||||
msg = ac1._evtracker.wait_next_incoming_message()
|
||||
assert msg.text == "This will arrive"
|
||||
message_texts = [m.text for m in chat_on_ac1.get_messages()]
|
||||
assert len(message_texts) == 2
|
||||
assert "First group message" in message_texts
|
||||
assert "This will arrive" in message_texts
|
||||
|
||||
lp.sec("ac2 removes ac1 from their group")
|
||||
assert ac1.get_self_contact() in chat_on_ac1.get_contacts()
|
||||
assert contact.is_blocked()
|
||||
chat_on_ac2.remove_contact(ac1)
|
||||
ac1._evtracker.get_matching("DC_EVENT_CHAT_MODIFIED")
|
||||
assert not ac1.get_self_contact() in chat_on_ac1.get_contacts()
|
||||
|
||||
def test_set_get_group_image(self, acfactory, data, lp):
|
||||
ac1, ac2 = acfactory.get_two_online_accounts()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user