mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 13:26:28 +03:00
cargo-fmt only
This commit is contained in:
@@ -600,93 +600,91 @@ unsafe fn add_parts(
|
|||||||
let icnt = mime_parser.parts.len();
|
let icnt = mime_parser.parts.len();
|
||||||
let mut txt_raw = None;
|
let mut txt_raw = None;
|
||||||
|
|
||||||
context
|
context.sql.prepare(
|
||||||
.sql
|
"INSERT INTO msgs \
|
||||||
.prepare(
|
(rfc724_mid, server_folder, server_uid, chat_id, from_id, to_id, timestamp, \
|
||||||
"INSERT INTO msgs \
|
timestamp_sent, timestamp_rcvd, type, state, msgrmsg, txt, txt_raw, param, \
|
||||||
(rfc724_mid, server_folder, server_uid, chat_id, from_id, to_id, timestamp, \
|
bytes, hidden, mime_headers, mime_in_reply_to, mime_references) \
|
||||||
timestamp_sent, timestamp_rcvd, type, state, msgrmsg, txt, txt_raw, param, \
|
VALUES (?,?,?,?,?,?, ?,?,?,?,?,?, ?,?,?,?,?,?, ?,?);",
|
||||||
bytes, hidden, mime_headers, mime_in_reply_to, mime_references) \
|
|mut stmt, conn| {
|
||||||
VALUES (?,?,?,?,?,?, ?,?,?,?,?,?, ?,?,?,?,?,?, ?,?);",
|
for i in 0..icnt {
|
||||||
|mut stmt, conn| {
|
let part = &mut mime_parser.parts[i];
|
||||||
for i in 0..icnt {
|
if part.is_meta {
|
||||||
let part = &mut mime_parser.parts[i];
|
continue;
|
||||||
if part.is_meta {
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(ref msg) = part.msg {
|
if let Some(ref msg) = part.msg {
|
||||||
if mime_parser.location_kml.is_some()
|
if mime_parser.location_kml.is_some()
|
||||||
&& icnt == 1
|
&& icnt == 1
|
||||||
&& (msg == "-location-" || msg.is_empty())
|
&& (msg == "-location-" || msg.is_empty())
|
||||||
{
|
{
|
||||||
*hidden = 1;
|
*hidden = 1;
|
||||||
if state == MessageState::InFresh {
|
if state == MessageState::InFresh {
|
||||||
state = MessageState::InNoticed;
|
state = MessageState::InNoticed;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if part.typ == Viewtype::Text {
|
|
||||||
let msg_raw = part.msg_raw.as_ref().cloned().unwrap_or_default();
|
|
||||||
let subject = mime_parser
|
|
||||||
.subject
|
|
||||||
.as_ref()
|
|
||||||
.map(|s| s.to_string())
|
|
||||||
.unwrap_or("".into());
|
|
||||||
txt_raw = Some(format!("{}\n\n{}", subject, msg_raw));
|
|
||||||
}
|
|
||||||
if mime_parser.is_system_message != SystemMessage::Unknown {
|
|
||||||
part.param
|
|
||||||
.set_int(Param::Cmd, mime_parser.is_system_message as i32);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
info!(
|
|
||||||
context,
|
|
||||||
"received mime message {:?}",
|
|
||||||
String::from_utf8_lossy(std::slice::from_raw_parts(
|
|
||||||
imf_raw_not_terminated as *const u8,
|
|
||||||
imf_raw_bytes,
|
|
||||||
))
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
stmt.execute(params![
|
|
||||||
rfc724_mid,
|
|
||||||
server_folder.as_ref(),
|
|
||||||
server_uid as libc::c_int,
|
|
||||||
*chat_id as libc::c_int,
|
|
||||||
*from_id as libc::c_int,
|
|
||||||
*to_id as libc::c_int,
|
|
||||||
sort_timestamp,
|
|
||||||
*sent_timestamp,
|
|
||||||
rcvd_timestamp,
|
|
||||||
part.typ,
|
|
||||||
state,
|
|
||||||
msgrmsg,
|
|
||||||
part.msg.as_ref().map_or("", String::as_str),
|
|
||||||
// txt_raw might contain invalid utf8
|
|
||||||
txt_raw.unwrap_or_default(),
|
|
||||||
part.param.to_string(),
|
|
||||||
part.bytes,
|
|
||||||
*hidden,
|
|
||||||
if save_mime_headers {
|
|
||||||
Some(String::from_utf8_lossy(imf_raw))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
},
|
|
||||||
mime_in_reply_to,
|
|
||||||
mime_references,
|
|
||||||
])?;
|
|
||||||
|
|
||||||
txt_raw = None;
|
|
||||||
*insert_msg_id =
|
|
||||||
sql::get_rowid_with_conn(context, conn, "msgs", "rfc724_mid", &rfc724_mid);
|
|
||||||
created_db_entries.push((*chat_id as usize, *insert_msg_id as usize));
|
|
||||||
}
|
}
|
||||||
Ok(())
|
if part.typ == Viewtype::Text {
|
||||||
},
|
let msg_raw = part.msg_raw.as_ref().cloned().unwrap_or_default();
|
||||||
)?;
|
let subject = mime_parser
|
||||||
|
.subject
|
||||||
|
.as_ref()
|
||||||
|
.map(|s| s.to_string())
|
||||||
|
.unwrap_or("".into());
|
||||||
|
txt_raw = Some(format!("{}\n\n{}", subject, msg_raw));
|
||||||
|
}
|
||||||
|
if mime_parser.is_system_message != SystemMessage::Unknown {
|
||||||
|
part.param
|
||||||
|
.set_int(Param::Cmd, mime_parser.is_system_message as i32);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
info!(
|
||||||
|
context,
|
||||||
|
"received mime message {:?}",
|
||||||
|
String::from_utf8_lossy(std::slice::from_raw_parts(
|
||||||
|
imf_raw_not_terminated as *const u8,
|
||||||
|
imf_raw_bytes,
|
||||||
|
))
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
stmt.execute(params![
|
||||||
|
rfc724_mid,
|
||||||
|
server_folder.as_ref(),
|
||||||
|
server_uid as libc::c_int,
|
||||||
|
*chat_id as libc::c_int,
|
||||||
|
*from_id as libc::c_int,
|
||||||
|
*to_id as libc::c_int,
|
||||||
|
sort_timestamp,
|
||||||
|
*sent_timestamp,
|
||||||
|
rcvd_timestamp,
|
||||||
|
part.typ,
|
||||||
|
state,
|
||||||
|
msgrmsg,
|
||||||
|
part.msg.as_ref().map_or("", String::as_str),
|
||||||
|
// txt_raw might contain invalid utf8
|
||||||
|
txt_raw.unwrap_or_default(),
|
||||||
|
part.param.to_string(),
|
||||||
|
part.bytes,
|
||||||
|
*hidden,
|
||||||
|
if save_mime_headers {
|
||||||
|
Some(String::from_utf8_lossy(imf_raw))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
|
mime_in_reply_to,
|
||||||
|
mime_references,
|
||||||
|
])?;
|
||||||
|
|
||||||
|
txt_raw = None;
|
||||||
|
*insert_msg_id =
|
||||||
|
sql::get_rowid_with_conn(context, conn, "msgs", "rfc724_mid", &rfc724_mid);
|
||||||
|
created_db_entries.push((*chat_id as usize, *insert_msg_id as usize));
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
context,
|
context,
|
||||||
|
|||||||
Reference in New Issue
Block a user