fix: Use ChatIdBlocked::lookup_by_contact() instead of ChatId's method when applicable

`ChatId::lookup_by_contact()` returns `None` for blocked chats, so it should be only used if we need
to filter out blocked chats, e.g. when building a chatlist.
This commit is contained in:
iequidoo
2024-05-07 03:09:23 -03:00
committed by iequidoo
parent e3cb9b894b
commit ab1583eef9
4 changed files with 21 additions and 11 deletions

View File

@@ -2303,7 +2303,9 @@ async fn update_special_chat_name(
contact_id: ContactId,
name: String,
) -> Result<()> {
if let Some(chat_id) = ChatId::lookup_by_contact(context, contact_id).await? {
if let Some(ChatIdBlocked { id: chat_id, .. }) =
ChatIdBlocked::lookup_by_contact(context, contact_id).await?
{
// the `!= name` condition avoids unneeded writes
context
.sql
@@ -4478,9 +4480,10 @@ impl Context {
}
_ => (),
}
ChatId::lookup_by_contact(self, contact_id)
ChatIdBlocked::lookup_by_contact(self, contact_id)
.await?
.with_context(|| format!("No chat for addr '{addr}'"))?
.id
}
SyncId::Grpid(grpid) => {
if let SyncAction::CreateBroadcast(name) = action {