From 97b1a1c392b73e1cce8a453ae4535e2c4d90eb24 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 19 Sep 2020 18:19:55 +0300 Subject: [PATCH] Set contact ID in event related to contact blocking --- python/tests/test_account.py | 2 ++ src/contact.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/python/tests/test_account.py b/python/tests/test_account.py index f9f3c24e2..259a64ca1 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -1417,6 +1417,8 @@ class TestOnlineAccount: contact = ac1.create_contact(ac2) contact.set_blocked() assert contact.is_blocked() + ev = ac1._evtracker.get_matching("DC_EVENT_CONTACTS_CHANGED") + assert ev.data1 == contact.id 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!") diff --git a/src/contact.rs b/src/contact.rs index 678f52cee..8ee851d35 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -1090,12 +1090,12 @@ async fn set_block_contact(context: &Context, contact_id: u32, new_blocking: boo // However, I'm not sure about this point; it may be confusing if the user wants to add other people; // this would result in recreating the same group...) if context.sql.execute( - "UPDATE chats SET blocked=? WHERE type=? AND id IN (SELECT chat_id FROM chats_contacts WHERE contact_id=?);", - paramsv![new_blocking, 100, contact_id as i32], - ).await.is_ok() { - Contact::mark_noticed(context, contact_id).await; - context.emit_event(EventType::ContactsChanged(None)); - } + "UPDATE chats SET blocked=? WHERE type=? AND id IN (SELECT chat_id FROM chats_contacts WHERE contact_id=?);", + paramsv![new_blocking, 100, contact_id as i32]).await.is_ok() + { + Contact::mark_noticed(context, contact_id).await; + context.emit_event(EventType::ContactsChanged(Some(contact_id))); + } } } }