mirror of
https://github.com/chatmail/core.git
synced 2026-06-28 18:46:35 +03:00
Compare commits
3 Commits
fix355
...
refactor/r
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48235999ae | ||
|
|
050da28e26 | ||
|
|
090a38a1fe |
@@ -1307,9 +1307,7 @@ pub unsafe fn dc_get_next_media(
|
||||
}
|
||||
}
|
||||
|
||||
if !list.is_null() {
|
||||
dc_array_unref(list);
|
||||
}
|
||||
dc_array_unref(list);
|
||||
dc_msg_unref(msg);
|
||||
ret_msg_id
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ macro_rules! progress {
|
||||
Event::CONFIGURE_PROGRESS,
|
||||
(if $progress < 1 {
|
||||
1
|
||||
} else if $progress > 1000 {
|
||||
1000
|
||||
} else if $progress > 999 {
|
||||
999
|
||||
} else {
|
||||
$progress
|
||||
}) as uintptr_t,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use itertools::join;
|
||||
|
||||
use mmime::mailimf::*;
|
||||
use mmime::mailimf_types::*;
|
||||
use mmime::mailmime::*;
|
||||
@@ -1506,12 +1504,8 @@ unsafe fn create_or_lookup_adhoc_group(
|
||||
ret_chat_id_blocked: *mut libc::c_int,
|
||||
chat_id: u32,
|
||||
chat_id_blocked: i32| {
|
||||
if !member_ids.is_null() {
|
||||
dc_array_unref(member_ids);
|
||||
}
|
||||
if !chat_ids.is_null() {
|
||||
dc_array_unref(chat_ids);
|
||||
}
|
||||
dc_array_unref(member_ids);
|
||||
dc_array_unref(chat_ids);
|
||||
free(chat_ids_str as *mut libc::c_void);
|
||||
free(grpid as *mut libc::c_void);
|
||||
free(grpname as *mut libc::c_void);
|
||||
@@ -1746,8 +1740,9 @@ unsafe fn search_chat_ids_by_contact_ids(
|
||||
unsorted_contact_ids: *const dc_array_t,
|
||||
) -> *mut dc_array_t {
|
||||
/* searches chat_id's by the given contact IDs, may return zero, one or more chat_id's */
|
||||
let mut contact_ids = Vec::with_capacity(23);
|
||||
let mut chat_ids = Vec::with_capacity(23);
|
||||
let contact_ids: *mut dc_array_t = dc_array_new(23 as size_t);
|
||||
let mut contact_ids_str: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let chat_ids: *mut dc_array_t = dc_array_new(23 as size_t);
|
||||
|
||||
/* copy array, remove duplicates and SELF, sort by ID */
|
||||
let mut i: libc::c_int;
|
||||
@@ -1756,18 +1751,22 @@ unsafe fn search_chat_ids_by_contact_ids(
|
||||
i = 0;
|
||||
while i < iCnt {
|
||||
let curr_id: uint32_t = dc_array_get_id(unsorted_contact_ids, i as size_t);
|
||||
if curr_id != 1 as libc::c_uint && !contact_ids.contains(&curr_id) {
|
||||
contact_ids.push(curr_id);
|
||||
if curr_id != 1 as libc::c_uint
|
||||
&& !dc_array_search_id(contact_ids, curr_id, 0 as *mut size_t)
|
||||
{
|
||||
dc_array_add_id(contact_ids, curr_id);
|
||||
}
|
||||
i += 1
|
||||
}
|
||||
if !contact_ids.is_empty() {
|
||||
contact_ids.sort();
|
||||
let contact_ids_str = join(contact_ids.iter().map(|x| x.to_string()), ",");
|
||||
if !(dc_array_get_cnt(contact_ids) == 0) {
|
||||
(*contact_ids).sort_ids();
|
||||
contact_ids_str =
|
||||
dc_array_get_string(contact_ids, b",\x00" as *const u8 as *const libc::c_char);
|
||||
|
||||
context.sql.query_map(
|
||||
format!(
|
||||
"SELECT DISTINCT cc.chat_id, cc.contact_id FROM chats_contacts cc LEFT JOIN chats c ON c.id=cc.chat_id WHERE cc.chat_id IN(SELECT chat_id FROM chats_contacts WHERE contact_id IN({})) AND c.type=120 AND cc.contact_id!=1 ORDER BY cc.chat_id, cc.contact_id;",
|
||||
contact_ids_str
|
||||
as_str(contact_ids_str)
|
||||
),
|
||||
params![],
|
||||
|row| Ok((row.get::<_, i32>(0)?, row.get::<_, i32>(1)?)),
|
||||
@@ -1779,30 +1778,32 @@ unsafe fn search_chat_ids_by_contact_ids(
|
||||
for row in rows {
|
||||
let (chat_id, contact_id) = row?;
|
||||
if chat_id as u32 != last_chat_id {
|
||||
if matches == contact_ids.len() && mismatches == 0 {
|
||||
chat_ids.push(last_chat_id);
|
||||
if matches == dc_array_get_cnt(contact_ids) && mismatches == 0 {
|
||||
dc_array_add_id(chat_ids, last_chat_id);
|
||||
}
|
||||
last_chat_id = chat_id as u32;
|
||||
matches = 0;
|
||||
mismatches = 0;
|
||||
}
|
||||
if contact_id as u32 == contact_ids[matches] {
|
||||
if contact_id as u32 == dc_array_get_id(contact_ids, matches as size_t) {
|
||||
matches += 1;
|
||||
} else {
|
||||
mismatches += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if matches == contact_ids.len() && mismatches == 0 {
|
||||
chat_ids.push(last_chat_id);
|
||||
if matches == dc_array_get_cnt(contact_ids) && mismatches == 0 {
|
||||
dc_array_add_id(chat_ids, last_chat_id);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
).unwrap(); // TODO: better error handling
|
||||
}
|
||||
}
|
||||
free(contact_ids_str as *mut libc::c_void);
|
||||
dc_array_unref(contact_ids);
|
||||
|
||||
dc_array_t::from(chat_ids).into_raw()
|
||||
chat_ids
|
||||
}
|
||||
|
||||
unsafe fn check_verified_properties(
|
||||
|
||||
Reference in New Issue
Block a user