mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 06:46:32 +03:00
fix: Make it possible to leave and immediately delete a chat (#7744)
Without this PR, if you leave and immediately delete a chat, the leave message won't be sent. This is needed for https://github.com/deltachat/deltachat-android/issues/4158.
This commit is contained in:
@@ -1177,6 +1177,30 @@ def test_leave_broadcast(acfactory, all_devices_online):
|
|||||||
check_account(bob2, bob2.create_contact(alice), inviter_side=False)
|
check_account(bob2, bob2.create_contact(alice), inviter_side=False)
|
||||||
|
|
||||||
|
|
||||||
|
def test_leave_and_delete_group(acfactory, log):
|
||||||
|
alice, bob = acfactory.get_online_accounts(2)
|
||||||
|
|
||||||
|
log.section("Alice creates a group")
|
||||||
|
alice_chat = alice.create_group("Group")
|
||||||
|
alice_chat.add_contact(bob)
|
||||||
|
assert len(alice_chat.get_contacts()) == 2 # Alice and Bob
|
||||||
|
alice_chat.send_text("hello")
|
||||||
|
|
||||||
|
log.section("Bob sees the group, and leaves and deletes it")
|
||||||
|
msg = bob.wait_for_incoming_msg().get_snapshot()
|
||||||
|
assert msg.text == "hello"
|
||||||
|
msg.chat.accept()
|
||||||
|
|
||||||
|
msg.chat.leave()
|
||||||
|
# Bob deletes the chat. This must not prevent the leave message from being sent.
|
||||||
|
msg.chat.delete()
|
||||||
|
|
||||||
|
log.section("Alice receives the delete message")
|
||||||
|
# After Bob left, only Alice will be left in the group:
|
||||||
|
while len(alice_chat.get_contacts()) != 1:
|
||||||
|
alice.wait_for_event(EventType.CHAT_MODIFIED)
|
||||||
|
|
||||||
|
|
||||||
def test_immediate_autodelete(acfactory, direct_imap, log):
|
def test_immediate_autodelete(acfactory, direct_imap, log):
|
||||||
ac1, ac2 = acfactory.get_online_accounts(2)
|
ac1, ac2 = acfactory.get_online_accounts(2)
|
||||||
|
|
||||||
|
|||||||
@@ -635,10 +635,6 @@ impl ChatId {
|
|||||||
"UPDATE imap SET target=? WHERE rfc724_mid IN (SELECT pre_rfc724_mid FROM msgs WHERE chat_id=? AND pre_rfc724_mid!='')",
|
"UPDATE imap SET target=? WHERE rfc724_mid IN (SELECT pre_rfc724_mid FROM msgs WHERE chat_id=? AND pre_rfc724_mid!='')",
|
||||||
(&delete_msgs_target, self,),
|
(&delete_msgs_target, self,),
|
||||||
)?;
|
)?;
|
||||||
transaction.execute(
|
|
||||||
"DELETE FROM smtp WHERE msg_id IN (SELECT id FROM msgs WHERE chat_id=?)",
|
|
||||||
(self,),
|
|
||||||
)?;
|
|
||||||
transaction.execute(
|
transaction.execute(
|
||||||
"DELETE FROM msgs_mdns WHERE msg_id IN (SELECT id FROM msgs WHERE chat_id=?)",
|
"DELETE FROM msgs_mdns WHERE msg_id IN (SELECT id FROM msgs WHERE chat_id=?)",
|
||||||
(self,),
|
(self,),
|
||||||
|
|||||||
Reference in New Issue
Block a user