fix: do not return hidden chat from dc_get_chat_id_by_contact_id

This commit is contained in:
link2xt
2023-11-09 03:59:01 +00:00
parent 0b664e75cb
commit d4d6ced957
2 changed files with 16 additions and 6 deletions

View File

@@ -215,9 +215,16 @@ impl ChatId {
context: &Context,
contact_id: ContactId,
) -> Result<Option<Self>> {
ChatIdBlocked::lookup_by_contact(context, contact_id)
.await
.map(|lookup| lookup.map(|chat| chat.id))
let Some(chat_id_blocked) = ChatIdBlocked::lookup_by_contact(context, contact_id).await?
else {
return Ok(None);
};
let chat_id = match chat_id_blocked.blocked {
Blocked::Not | Blocked::Request => Some(chat_id_blocked.id),
Blocked::Yes => None,
};
Ok(chat_id)
}
/// Returns the [`ChatId`] for the 1:1 chat with `contact_id`.