Set contact ID in event related to contact blocking

This commit is contained in:
Alexander Krotov
2020-09-19 18:19:55 +03:00
committed by link2xt
parent fe1c99c5e8
commit 97b1a1c392
2 changed files with 8 additions and 6 deletions

View File

@@ -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!")

View File

@@ -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)));
}
}
}
}