Resultify Contact::lookup_id_by_addr

Using a Contact ID as an error type is risky and a C leftover.
This commit is contained in:
Floris Bruynooghe
2021-01-24 16:57:22 +01:00
parent 6b9b39b953
commit 785cc795e3
6 changed files with 99 additions and 51 deletions

View File

@@ -1730,8 +1730,9 @@ async fn ndn_maybe_add_info_msg(
) -> anyhow::Result<()> {
if chat_type == Chattype::Group {
if let Some(failed_recipient) = &failed.failed_recipient {
let contact_id =
Contact::lookup_id_by_addr(context, failed_recipient, Origin::Unknown).await;
let contact_id = Contact::lookup_id_by_addr(context, failed_recipient, Origin::Unknown)
.await?
.ok_or_else(|| Error::msg("ndn_maybe_add_info_msg: Contact ID not found"))?;
let contact = Contact::load_from_db(context, contact_id).await?;
// Tell the user which of the recipients failed if we know that (because in a group, this might otherwise be unclear)
let text = context