mirror of
https://github.com/chatmail/core.git
synced 2026-05-20 15:26:30 +03:00
Merge pull request #471 from deltachat/fix417
fix crash when downloading message
This commit is contained in:
@@ -923,7 +923,7 @@ unsafe fn handle_reports(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn save_locations(
|
fn save_locations(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
mime_parser: &dc_mimeparser_t,
|
mime_parser: &dc_mimeparser_t,
|
||||||
chat_id: u32,
|
chat_id: u32,
|
||||||
@@ -1681,10 +1681,7 @@ fn hex_hash(s: impl AsRef<str>) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
unsafe fn search_chat_ids_by_contact_ids(
|
fn search_chat_ids_by_contact_ids(context: &Context, unsorted_contact_ids: &Vec<u32>) -> Vec<u32> {
|
||||||
context: &Context,
|
|
||||||
unsorted_contact_ids: &Vec<u32>,
|
|
||||||
) -> Vec<u32> {
|
|
||||||
/* searches chat_id's by the given contact IDs, may return zero, one or more chat_id's */
|
/* 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 contact_ids = Vec::with_capacity(23);
|
||||||
let mut chat_ids = Vec::with_capacity(23);
|
let mut chat_ids = Vec::with_capacity(23);
|
||||||
@@ -1701,7 +1698,13 @@ unsafe fn search_chat_ids_by_contact_ids(
|
|||||||
let contact_ids_str = join(contact_ids.iter().map(|x| x.to_string()), ",");
|
let contact_ids_str = join(contact_ids.iter().map(|x| x.to_string()), ",");
|
||||||
context.sql.query_map(
|
context.sql.query_map(
|
||||||
format!(
|
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;",
|
"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
|
contact_ids_str
|
||||||
),
|
),
|
||||||
params![],
|
params![],
|
||||||
@@ -1713,15 +1716,15 @@ unsafe fn search_chat_ids_by_contact_ids(
|
|||||||
|
|
||||||
for row in rows {
|
for row in rows {
|
||||||
let (chat_id, contact_id) = row?;
|
let (chat_id, contact_id) = row?;
|
||||||
if chat_id as u32 != last_chat_id {
|
if chat_id != last_chat_id {
|
||||||
if matches == contact_ids.len() && mismatches == 0 {
|
if matches == contact_ids.len() && mismatches == 0 {
|
||||||
chat_ids.push(last_chat_id);
|
chat_ids.push(last_chat_id);
|
||||||
}
|
}
|
||||||
last_chat_id = chat_id as u32;
|
last_chat_id = chat_id;
|
||||||
matches = 0;
|
matches = 0;
|
||||||
mismatches = 0;
|
mismatches = 0;
|
||||||
}
|
}
|
||||||
if contact_id == contact_ids[matches] {
|
if matches < contact_ids.len() && contact_id == contact_ids[matches] {
|
||||||
matches += 1;
|
matches += 1;
|
||||||
} else {
|
} else {
|
||||||
mismatches += 1;
|
mismatches += 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user