mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 14:56:33 +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;
|
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]
|
#[no_mangle]
|
||||||
@@ -1655,7 +1661,10 @@ pub unsafe extern "C" fn dc_get_blocked_contacts(
|
|||||||
|
|
||||||
block_on(async move {
|
block_on(async move {
|
||||||
Box::into_raw(Box::new(dc_array_t::from(
|
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;
|
Contact::unblock(&context, contact_id).await;
|
||||||
}
|
}
|
||||||
"listblocked" => {
|
"listblocked" => {
|
||||||
let contacts = Contact::get_all_blocked(&context).await;
|
let contacts = Contact::get_all_blocked(&context).await?;
|
||||||
log_contactlist(&context, &contacts).await;
|
log_contactlist(&context, &contacts).await;
|
||||||
println!("{} blocked contacts.", contacts.len());
|
println!("{} blocked contacts.", contacts.len());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -675,8 +675,8 @@ impl Contact {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get blocked contacts.
|
/// Get blocked contacts.
|
||||||
pub async fn get_all_blocked(context: &Context) -> Vec<u32> {
|
pub async fn get_all_blocked(context: &Context) -> Result<Vec<u32>> {
|
||||||
context
|
let ret = context
|
||||||
.sql
|
.sql
|
||||||
.query_map(
|
.query_map(
|
||||||
"SELECT id FROM contacts WHERE id>? AND blocked!=0 ORDER BY LOWER(iif(name='',authname,name)||addr),id;",
|
"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)
|
.map_err(Into::into)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
.unwrap_or_default()
|
Ok(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a textual summary of the encryption state for the contact.
|
/// Returns a textual summary of the encryption state for the contact.
|
||||||
|
|||||||
Reference in New Issue
Block a user