mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
Return Vec from get_all_blocked
And never return nullptr from dc_get_blocked_contacts.
This commit is contained in:
committed by
holger krekel
parent
9cf6ca045c
commit
88a81f5737
@@ -837,7 +837,7 @@ pub unsafe extern "C" fn dc_get_blocked_contacts(
|
|||||||
assert!(!context.is_null());
|
assert!(!context.is_null());
|
||||||
let context = &*context;
|
let context = &*context;
|
||||||
|
|
||||||
Contact::get_all_blocked(context)
|
dc_array_t::from(Contact::get_all_blocked(context)).into_raw()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use crate::aheader::EncryptPreference;
|
|||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::dc_array::*;
|
|
||||||
use crate::dc_e2ee::*;
|
use crate::dc_e2ee::*;
|
||||||
use crate::dc_loginparam::*;
|
use crate::dc_loginparam::*;
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
@@ -564,24 +563,19 @@ impl<'a> Contact<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get blocked contacts.
|
/// Get blocked contacts.
|
||||||
pub fn get_all_blocked(context: &Context) -> *mut dc_array_t {
|
pub fn get_all_blocked(context: &Context) -> Vec<u32> {
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.query_map(
|
.query_map(
|
||||||
"SELECT id FROM contacts WHERE id>? AND blocked!=0 ORDER BY LOWER(name||addr),id;",
|
"SELECT id FROM contacts WHERE id>? AND blocked!=0 ORDER BY LOWER(name||addr),id;",
|
||||||
params![DC_CONTACT_ID_LAST_SPECIAL as i32],
|
params![DC_CONTACT_ID_LAST_SPECIAL as i32],
|
||||||
|row| row.get::<_, i32>(0),
|
|row| row.get::<_, u32>(0),
|
||||||
|ids| {
|
|ids| {
|
||||||
let mut ret = Vec::new();
|
ids.collect::<std::result::Result<Vec<_>, _>>()
|
||||||
|
.map_err(Into::into)
|
||||||
for id in ids {
|
|
||||||
ret.push(id? as u32);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(dc_array_t::from(ret).into_raw())
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|_| std::ptr::null_mut())
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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