mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 10:26:29 +03:00
resultify Contact::get_all_blocked()
This commit is contained in:
@@ -1640,7 +1640,13 @@ pub unsafe extern "C" fn dc_get_blocked_cnt(context: *mut dc_context_t) -> libc:
|
||||
}
|
||||
let ctx = &*context;
|
||||
|
||||
block_on(async move { Contact::get_all_blocked(&ctx).await.len() as libc::c_int })
|
||||
block_on(async move {
|
||||
Contact::get_all_blocked(&ctx)
|
||||
.await
|
||||
.log_err(&ctx, "Can't get blocked count")
|
||||
.unwrap_or_default()
|
||||
.len() as libc::c_int
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -1655,7 +1661,10 @@ pub unsafe extern "C" fn dc_get_blocked_contacts(
|
||||
|
||||
block_on(async move {
|
||||
Box::into_raw(Box::new(dc_array_t::from(
|
||||
Contact::get_all_blocked(&ctx).await,
|
||||
Contact::get_all_blocked(&ctx)
|
||||
.await
|
||||
.log_err(&ctx, "Can't get blocked contacts")
|
||||
.unwrap_or_default(),
|
||||
)))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1103,7 +1103,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
|
||||
Contact::unblock(&context, contact_id).await;
|
||||
}
|
||||
"listblocked" => {
|
||||
let contacts = Contact::get_all_blocked(&context).await;
|
||||
let contacts = Contact::get_all_blocked(&context).await?;
|
||||
log_contactlist(&context, &contacts).await;
|
||||
println!("{} blocked contacts.", contacts.len());
|
||||
}
|
||||
|
||||
@@ -675,8 +675,8 @@ impl Contact {
|
||||
}
|
||||
|
||||
/// Get blocked contacts.
|
||||
pub async fn get_all_blocked(context: &Context) -> Vec<u32> {
|
||||
context
|
||||
pub async fn get_all_blocked(context: &Context) -> Result<Vec<u32>> {
|
||||
let ret = context
|
||||
.sql
|
||||
.query_map(
|
||||
"SELECT id FROM contacts WHERE id>? AND blocked!=0 ORDER BY LOWER(iif(name='',authname,name)||addr),id;",
|
||||
@@ -687,8 +687,8 @@ impl Contact {
|
||||
.map_err(Into::into)
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.await?;
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
/// Returns a textual summary of the encryption state for the contact.
|
||||
|
||||
Reference in New Issue
Block a user