mirror of
https://github.com/chatmail/core.git
synced 2026-05-05 06:16:30 +03:00
fix(message): avoid nested sql statement in dc_get_msg_info
Closes #410
This commit is contained in:
@@ -208,33 +208,28 @@ pub unsafe fn dc_get_msg_info(context: &Context, msg_id: u32) -> *mut libc::c_ch
|
|||||||
return ret.strdup();
|
return ret.strdup();
|
||||||
}
|
}
|
||||||
|
|
||||||
context
|
if let Ok(rows) = context.sql.query_map(
|
||||||
.sql
|
"SELECT contact_id, timestamp_sent FROM msgs_mdns WHERE msg_id=?;",
|
||||||
.query_map(
|
params![msg_id as i32],
|
||||||
"SELECT contact_id, timestamp_sent FROM msgs_mdns WHERE msg_id=?;",
|
|row| {
|
||||||
params![msg_id as i32],
|
let contact_id: i32 = row.get(0)?;
|
||||||
|row| {
|
let ts: i64 = row.get(1)?;
|
||||||
let contact_id: i32 = row.get(0)?;
|
Ok((contact_id, ts))
|
||||||
let ts: i64 = row.get(1)?;
|
},
|
||||||
Ok((contact_id, ts))
|
|rows| rows.collect::<Result<Vec<_>, _>>().map_err(Into::into),
|
||||||
},
|
) {
|
||||||
|rows| {
|
for (contact_id, ts) in rows {
|
||||||
for row in rows {
|
let fts = dc_timestamp_to_str(ts);
|
||||||
let (contact_id, ts) = row?;
|
ret += &format!("Read: {}", fts);
|
||||||
let fts = dc_timestamp_to_str(ts);
|
|
||||||
ret += &format!("Read: {}", fts);
|
|
||||||
|
|
||||||
let name = Contact::load_from_db(context, contact_id as u32)
|
let name = Contact::load_from_db(context, contact_id as u32)
|
||||||
.map(|contact| contact.get_name_n_addr())
|
.map(|contact| contact.get_name_n_addr())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
ret += &format!(" by {}", name);
|
ret += &format!(" by {}", name);
|
||||||
ret += "\n";
|
ret += "\n";
|
||||||
}
|
}
|
||||||
Ok(())
|
}
|
||||||
},
|
|
||||||
)
|
|
||||||
.unwrap(); // TODO: better error handling
|
|
||||||
|
|
||||||
ret += "State: ";
|
ret += "State: ";
|
||||||
use MessageState::*;
|
use MessageState::*;
|
||||||
|
|||||||
Reference in New Issue
Block a user