mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 13:36:30 +03:00
Fix some clippy warnings
This commit is contained in:
committed by
holger krekel
parent
a5c4e16405
commit
130d485cac
@@ -88,18 +88,15 @@ impl Aheader {
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
match Self::from_str(value) {
|
||||
Ok(test) => {
|
||||
if addr_cmp(&test.addr, wanted_from) {
|
||||
if fine_header.is_none() {
|
||||
fine_header = Some(test);
|
||||
} else {
|
||||
// TODO: figure out what kind of error case this is
|
||||
return None;
|
||||
}
|
||||
if let Ok(test) = Self::from_str(value) {
|
||||
if addr_cmp(&test.addr, wanted_from) {
|
||||
if fine_header.is_none() {
|
||||
fine_header = Some(test);
|
||||
} else {
|
||||
// TODO: figure out what kind of error case this is
|
||||
return None;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,9 +128,9 @@ impl str::FromStr for Aheader {
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let mut attributes: BTreeMap<String, String> = s
|
||||
.split(";")
|
||||
.split(';')
|
||||
.filter_map(|a| {
|
||||
let attribute: Vec<&str> = a.trim().splitn(2, "=").collect();
|
||||
let attribute: Vec<&str> = a.trim().splitn(2, '=').collect();
|
||||
if attribute.len() < 2 {
|
||||
return None;
|
||||
}
|
||||
@@ -178,7 +175,7 @@ impl str::FromStr for Aheader {
|
||||
|
||||
// Autocrypt-Level0: unknown attributes starting with an underscore can be safely ignored
|
||||
// Autocrypt-Level0: unknown attribute, treat the header as invalid
|
||||
if attributes.keys().find(|k| !k.starts_with("_")).is_some() {
|
||||
if attributes.keys().any(|k| !k.starts_with('_')) {
|
||||
return Err(());
|
||||
}
|
||||
|
||||
|
||||
38
src/chat.rs
38
src/chat.rs
@@ -152,12 +152,10 @@ impl Chat {
|
||||
return context.stock_str(StockMessage::DeadDrop).into();
|
||||
}
|
||||
let cnt = get_chat_contact_cnt(context, self.id);
|
||||
return context
|
||||
.stock_string_repl_int(StockMessage::Member, cnt as i32)
|
||||
.into();
|
||||
return context.stock_string_repl_int(StockMessage::Member, cnt as i32);
|
||||
}
|
||||
|
||||
return "Err".into();
|
||||
"Err".to_string()
|
||||
}
|
||||
|
||||
pub fn get_parent_mime_headers(&self, context: &Context) -> Option<(String, String, String)> {
|
||||
@@ -799,10 +797,8 @@ pub fn send_msg(context: &Context, chat_id: u32, msg: &mut Message) -> Result<u3
|
||||
if 0 == id {
|
||||
// avoid hanging if user tampers with db
|
||||
break;
|
||||
} else {
|
||||
if let Ok(mut copy) = Message::load_from_db(context, id as u32) {
|
||||
send_msg(context, 0, &mut copy)?;
|
||||
}
|
||||
} else if let Ok(mut copy) = Message::load_from_db(context, id as u32) {
|
||||
send_msg(context, 0, &mut copy)?;
|
||||
}
|
||||
}
|
||||
msg.param.remove(Param::PrepForwards);
|
||||
@@ -1392,14 +1388,14 @@ pub(crate) fn add_contact_to_chat_ex(
|
||||
}
|
||||
} else {
|
||||
// else continue and send status mail
|
||||
if chat.typ == Chattype::VerifiedGroup {
|
||||
if contact.is_verified(context) != VerifiedStatus::BidirectVerified {
|
||||
error!(
|
||||
context,
|
||||
"Only bidirectional verified contacts can be added to verified groups."
|
||||
);
|
||||
return Ok(false);
|
||||
}
|
||||
if chat.typ == Chattype::VerifiedGroup
|
||||
&& contact.is_verified(context) != VerifiedStatus::BidirectVerified
|
||||
{
|
||||
error!(
|
||||
context,
|
||||
"Only bidirectional verified contacts can be added to verified groups."
|
||||
);
|
||||
return Ok(false);
|
||||
}
|
||||
if !add_to_chat_contacts_table(context, chat_id, contact_id) {
|
||||
return Ok(false);
|
||||
@@ -1423,7 +1419,7 @@ pub(crate) fn add_contact_to_chat_ex(
|
||||
});
|
||||
}
|
||||
context.call_cb(Event::MsgsChanged { chat_id, msg_id: 0 });
|
||||
return Ok(true);
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn real_group_exists(context: &Context, chat_id: u32) -> bool {
|
||||
@@ -1591,7 +1587,7 @@ pub fn set_chat_name(
|
||||
let mut msg = Message::default();
|
||||
|
||||
if real_group_exists(context, chat_id) {
|
||||
if &chat.name == new_name.as_ref() {
|
||||
if chat.name == new_name.as_ref() {
|
||||
success = true;
|
||||
} else if !is_contact_in_chat(context, chat_id, 1) {
|
||||
emit_event!(
|
||||
@@ -1723,7 +1719,7 @@ pub fn forward_msgs(context: &Context, msg_ids: &[u32], chat_id: u32) -> Result<
|
||||
if let Ok(mut chat) = Chat::load_from_db(context, chat_id) {
|
||||
curr_timestamp = dc_create_smeared_timestamps(context, msg_ids.len());
|
||||
let idsstr = msg_ids
|
||||
.into_iter()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.fold(String::with_capacity(2 * msg_ids.len()), |acc, (i, n)| {
|
||||
(if i == 0 { acc } else { acc + "," }) + &n.to_string()
|
||||
@@ -1760,7 +1756,7 @@ pub fn forward_msgs(context: &Context, msg_ids: &[u32], chat_id: u32) -> Result<
|
||||
let new_msg_id: u32;
|
||||
if msg.state == MessageState::OutPreparing {
|
||||
let fresh9 = curr_timestamp;
|
||||
curr_timestamp = curr_timestamp + 1;
|
||||
curr_timestamp += 1;
|
||||
new_msg_id = chat
|
||||
.prepare_msg_raw(context, &mut msg, fresh9)
|
||||
.unwrap_or_default();
|
||||
@@ -1780,7 +1776,7 @@ pub fn forward_msgs(context: &Context, msg_ids: &[u32], chat_id: u32) -> Result<
|
||||
} else {
|
||||
msg.state = MessageState::OutPending;
|
||||
let fresh10 = curr_timestamp;
|
||||
curr_timestamp = curr_timestamp + 1;
|
||||
curr_timestamp += 1;
|
||||
new_msg_id = chat
|
||||
.prepare_msg_raw(context, &mut msg, fresh10)
|
||||
.unwrap_or_default();
|
||||
|
||||
@@ -258,13 +258,11 @@ impl Chatlist {
|
||||
let chat_loaded: Chat;
|
||||
let chat = if let Some(chat) = chat {
|
||||
chat
|
||||
} else if let Ok(chat) = Chat::load_from_db(context, self.ids[index].0) {
|
||||
chat_loaded = chat;
|
||||
&chat_loaded
|
||||
} else {
|
||||
if let Ok(chat) = Chat::load_from_db(context, self.ids[index].0) {
|
||||
chat_loaded = chat;
|
||||
&chat_loaded
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
let lastmsg_id = self.ids[index].1;
|
||||
|
||||
@@ -41,7 +41,7 @@ pub unsafe fn outlk_autodiscover(
|
||||
let ok_to_continue;
|
||||
let mut i = 0;
|
||||
loop {
|
||||
if !(i < 10) {
|
||||
if i >= 10 {
|
||||
ok_to_continue = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context) {
|
||||
ok_to_continue8 = true;
|
||||
break;
|
||||
}
|
||||
if !param_autoconfig.is_none() {
|
||||
if param_autoconfig.is_some() {
|
||||
ok_to_continue8 = false;
|
||||
break;
|
||||
}
|
||||
@@ -423,7 +423,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context) {
|
||||
.unwrap()
|
||||
.connect(context, ¶m)
|
||||
{
|
||||
if !param_autoconfig.is_none() {
|
||||
if param_autoconfig.is_some() {
|
||||
success = false;
|
||||
} else if s.shall_stop_ongoing {
|
||||
success = false;
|
||||
|
||||
@@ -390,20 +390,18 @@ impl Contact {
|
||||
}
|
||||
sth_modified = Modifier::Modified;
|
||||
}
|
||||
} else if sql::execute(
|
||||
context,
|
||||
&context.sql,
|
||||
"INSERT INTO contacts (name, addr, origin) VALUES(?, ?, ?);",
|
||||
params![name.as_ref(), addr, origin,],
|
||||
)
|
||||
.is_ok()
|
||||
{
|
||||
row_id = sql::get_rowid(context, &context.sql, "contacts", "addr", addr);
|
||||
sth_modified = Modifier::Created;
|
||||
} else {
|
||||
if sql::execute(
|
||||
context,
|
||||
&context.sql,
|
||||
"INSERT INTO contacts (name, addr, origin) VALUES(?, ?, ?);",
|
||||
params![name.as_ref(), addr, origin,],
|
||||
)
|
||||
.is_ok()
|
||||
{
|
||||
row_id = sql::get_rowid(context, &context.sql, "contacts", "addr", addr);
|
||||
sth_modified = Modifier::Created;
|
||||
} else {
|
||||
error!(context, "Cannot add contact.");
|
||||
}
|
||||
error!(context, "Cannot add contact.");
|
||||
}
|
||||
|
||||
Ok((row_id, sth_modified))
|
||||
@@ -827,7 +825,7 @@ impl Contact {
|
||||
if let Ok(contact) = Contact::load_from_db(context, contact_id) {
|
||||
if !contact.addr.is_empty() {
|
||||
let normalized_addr = addr_normalize(addr.as_ref());
|
||||
if &contact.addr == &normalized_addr {
|
||||
if contact.addr == normalized_addr {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -963,9 +961,9 @@ pub fn normalize_name(full_name: impl AsRef<str>) -> String {
|
||||
if len > 0 {
|
||||
let firstchar = full_name.as_bytes()[0];
|
||||
let lastchar = full_name.as_bytes()[len - 1];
|
||||
if firstchar == '\'' as u8 && lastchar == '\'' as u8
|
||||
|| firstchar == '\"' as u8 && lastchar == '\"' as u8
|
||||
|| firstchar == '<' as u8 && lastchar == '>' as u8
|
||||
if firstchar == b'\'' && lastchar == b'\''
|
||||
|| firstchar == b'\"' && lastchar == b'\"'
|
||||
|| firstchar == b'<' && lastchar == b'>'
|
||||
{
|
||||
full_name = &full_name[1..len - 1];
|
||||
}
|
||||
|
||||
@@ -164,21 +164,17 @@ impl<'a> MimeParser<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Some(optional_field) = self.lookup_optional_field("Chat-Content") {
|
||||
if optional_field == "location-streaming-enabled" {
|
||||
self.is_system_message = SystemMessage::LocationStreamingEnabled;
|
||||
}
|
||||
} else if let Some(optional_field) = self.lookup_optional_field("Chat-Content") {
|
||||
if optional_field == "location-streaming-enabled" {
|
||||
self.is_system_message = SystemMessage::LocationStreamingEnabled;
|
||||
}
|
||||
}
|
||||
if self.lookup_field("Chat-Group-Image").is_some() && !self.parts.is_empty() {
|
||||
let textpart = &self.parts[0];
|
||||
if textpart.typ == Viewtype::Text {
|
||||
if self.parts.len() >= 2 {
|
||||
let imgpart = &mut self.parts[1];
|
||||
if imgpart.typ == Viewtype::Image {
|
||||
imgpart.is_meta = true;
|
||||
}
|
||||
if textpart.typ == Viewtype::Text && self.parts.len() >= 2 {
|
||||
let imgpart = &mut self.parts[1];
|
||||
if imgpart.typ == Viewtype::Image {
|
||||
imgpart.is_meta = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,7 +255,7 @@ impl<'a> MimeParser<'a> {
|
||||
}
|
||||
if self.parts[0].typ == Viewtype::Image {
|
||||
if let Some(content_type) = self.lookup_optional_field("Chat-Content") {
|
||||
if content_type == "sticker".to_string() {
|
||||
if content_type == "sticker" {
|
||||
let part_mut = &mut self.parts[0];
|
||||
part_mut.typ = Viewtype::Sticker;
|
||||
}
|
||||
@@ -866,10 +862,8 @@ impl<'a> MimeParser<'a> {
|
||||
if !mb.is_null() {
|
||||
let from_addr_norm = addr_normalize(as_str((*mb).mb_addr_spec));
|
||||
let recipients = wrapmime::mailimf_get_recipients(self.header_root);
|
||||
if recipients.len() == 1 {
|
||||
if recipients.contains(from_addr_norm) {
|
||||
sender_equals_recipient = true;
|
||||
}
|
||||
if recipients.len() == 1 && recipients.contains(from_addr_norm) {
|
||||
sender_equals_recipient = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -996,14 +990,12 @@ unsafe fn mailmime_get_mime_type(mime: *mut Mailmime) -> (libc::c_int, Viewtype,
|
||||
) == 0i32
|
||||
{
|
||||
return (DC_MIMETYPE_TEXT_PLAIN, Viewtype::Text, None);
|
||||
} else {
|
||||
if strcmp(
|
||||
(*c).ct_subtype,
|
||||
b"html\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32
|
||||
{
|
||||
return (DC_MIMETYPE_TEXT_HTML, Viewtype::Text, None);
|
||||
}
|
||||
} else if strcmp(
|
||||
(*c).ct_subtype,
|
||||
b"html\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32
|
||||
{
|
||||
return (DC_MIMETYPE_TEXT_HTML, Viewtype::Text, None);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ pub unsafe fn dc_receive_imf(
|
||||
if mime_parser.sender_equals_recipient() {
|
||||
from_id = DC_CONTACT_ID_SELF;
|
||||
}
|
||||
} else if from_list.len() >= 1 {
|
||||
} else if !from_list.is_empty() {
|
||||
// if there is no from given, from_id stays 0 which is just fine. These messages
|
||||
// are very rare, however, we have to add them to the database (they go to the
|
||||
// "deaddrop" chat) to avoid a re-download from the server. See also [**]
|
||||
@@ -495,10 +495,12 @@ unsafe fn add_parts(
|
||||
// if the chat_id is blocked,
|
||||
// for unknown senders and non-delta messages set the state to NOTICED
|
||||
// to not result in a contact request (this would require the state FRESH)
|
||||
if Blocked::Not != chat_id_blocked && state == MessageState::InFresh {
|
||||
if !incoming_origin.is_verified() && msgrmsg == 0 {
|
||||
state = MessageState::InNoticed;
|
||||
}
|
||||
if Blocked::Not != chat_id_blocked
|
||||
&& state == MessageState::InFresh
|
||||
&& !incoming_origin.is_verified()
|
||||
&& msgrmsg == 0
|
||||
{
|
||||
state = MessageState::InNoticed;
|
||||
}
|
||||
} else {
|
||||
// Outgoing
|
||||
@@ -627,7 +629,7 @@ unsafe fn add_parts(
|
||||
}
|
||||
|
||||
if let Some(ref msg) = part.msg {
|
||||
if !mime_parser.location_kml.is_none()
|
||||
if mime_parser.location_kml.is_some()
|
||||
&& icnt == 1
|
||||
&& (msg == "-location-" || msg.is_empty())
|
||||
{
|
||||
@@ -1479,7 +1481,7 @@ fn create_group_record(
|
||||
sql::get_rowid(context, &context.sql, "chats", "grpid", grpid.as_ref())
|
||||
}
|
||||
|
||||
fn create_adhoc_grp_id(context: &Context, member_ids: &Vec<u32>) -> String {
|
||||
fn create_adhoc_grp_id(context: &Context, member_ids: &[u32]) -> String {
|
||||
/* algorithm:
|
||||
- sort normalized, lowercased, e-mail addresses alphabetically
|
||||
- put all e-mail addresses into a single string, separate the address by a single comma
|
||||
@@ -1591,7 +1593,7 @@ fn check_verified_properties(
|
||||
context: &Context,
|
||||
mimeparser: &MimeParser,
|
||||
from_id: u32,
|
||||
to_ids: &Vec<u32>,
|
||||
to_ids: &[u32],
|
||||
) -> Result<()> {
|
||||
let contact = Contact::load_from_db(context, from_id)?;
|
||||
|
||||
@@ -1711,13 +1713,13 @@ unsafe fn dc_is_reply_to_known_message(context: &Context, mime_parser: &MimePars
|
||||
if let Some(field) = mime_parser.lookup_field("References") {
|
||||
if (*field).fld_type == MAILIMF_FIELD_REFERENCES as libc::c_int {
|
||||
let fld_references = (*field).fld_data.fld_references;
|
||||
if !fld_references.is_null() {
|
||||
if is_known_rfc724_mid_in_list(
|
||||
if !fld_references.is_null()
|
||||
&& is_known_rfc724_mid_in_list(
|
||||
context,
|
||||
(*(*field).fld_data.fld_references).mid_list,
|
||||
) {
|
||||
return 1;
|
||||
}
|
||||
)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1731,12 +1733,12 @@ unsafe fn is_known_rfc724_mid_in_list(context: &Context, mid_list: *const clist)
|
||||
}
|
||||
|
||||
for data in &*mid_list {
|
||||
if 0 != is_known_rfc724_mid(context, data.cast()) {
|
||||
if is_known_rfc724_mid(context, data.cast()) != 0 {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
false
|
||||
}
|
||||
|
||||
/// Check if a message is a reply to a known message (messenger or non-messenger).
|
||||
@@ -1961,10 +1963,8 @@ unsafe fn add_or_lookup_contact_by_addr(
|
||||
let row_id = Contact::add_or_lookup(context, display_name_dec, as_str(addr_spec), origin)
|
||||
.map(|(id, _)| id)
|
||||
.unwrap_or_default();
|
||||
if 0 != row_id {
|
||||
if !ids.contains(&row_id) {
|
||||
ids.push(row_id);
|
||||
}
|
||||
if 0 != row_id && !ids.contains(&row_id) {
|
||||
ids.push(row_id);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,18 +10,16 @@ pub struct Simplify {
|
||||
///
|
||||
/// Also return whether not-standard (rfc3676, §4.3) footer is found.
|
||||
fn find_message_footer(lines: &[&str]) -> (usize, bool) {
|
||||
for ix in 0..lines.len() {
|
||||
let line = lines[ix];
|
||||
|
||||
for (ix, &line) in lines.iter().enumerate() {
|
||||
// quoted-printable may encode `-- ` to `-- =20` which is converted
|
||||
// back to `-- `
|
||||
match line.as_ref() {
|
||||
match line {
|
||||
"-- " | "-- " => return (ix, false),
|
||||
"--" | "---" | "----" => return (ix, true),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
return (lines.len(), false);
|
||||
(lines.len(), false)
|
||||
}
|
||||
|
||||
impl Simplify {
|
||||
@@ -103,10 +101,8 @@ impl Simplify {
|
||||
if let Some(last_quoted_line) = l_lastQuotedLine {
|
||||
l_last = last_quoted_line;
|
||||
is_cut_at_end = true;
|
||||
if l_last > 1 {
|
||||
if is_empty_line(lines[l_last - 1]) {
|
||||
l_last -= 1
|
||||
}
|
||||
if l_last > 1 && is_empty_line(lines[l_last - 1]) {
|
||||
l_last -= 1
|
||||
}
|
||||
if l_last > 1 {
|
||||
let line = lines[l_last - 1];
|
||||
@@ -205,7 +201,7 @@ fn is_quoted_headline(buf: &str) -> bool {
|
||||
}
|
||||
|
||||
fn is_plain_quote(buf: &str) -> bool {
|
||||
buf.starts_with(">")
|
||||
buf.starts_with('>')
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -141,7 +141,7 @@ pub(crate) fn dc_truncate(buf: &str, approx_chars: usize, do_unwrap: bool) -> Co
|
||||
.unwrap_or_default();
|
||||
|
||||
if let Some(index) = buf[..end_pos].rfind(|c| c == ' ' || c == '\n') {
|
||||
Cow::Owned(format!("{}{}", &buf[..index + 1], ellipse))
|
||||
Cow::Owned(format!("{}{}", &buf[..=index], ellipse))
|
||||
} else {
|
||||
Cow::Owned(format!("{}{}", &buf[..end_pos], ellipse))
|
||||
}
|
||||
@@ -334,14 +334,14 @@ fn encode_66bits_as_base64(v1: u32, v2: u32, fill: u32) -> String {
|
||||
enc.write_u8(((fill & 0x3) as u8) << 6).unwrap();
|
||||
enc.finish().unwrap();
|
||||
}
|
||||
assert_eq!(wrapped_writer.pop(), Some('A' as u8)); // Remove last "A"
|
||||
assert_eq!(wrapped_writer.pop(), Some(b'A')); // Remove last "A"
|
||||
String::from_utf8(wrapped_writer).unwrap()
|
||||
}
|
||||
|
||||
pub(crate) fn dc_create_incoming_rfc724_mid(
|
||||
message_timestamp: i64,
|
||||
contact_id_from: u32,
|
||||
contact_ids_to: &Vec<u32>,
|
||||
contact_ids_to: &[u32],
|
||||
) -> Option<String> {
|
||||
if contact_ids_to.is_empty() {
|
||||
return None;
|
||||
@@ -423,10 +423,10 @@ fn get_safe_basename(filename: &str) -> String {
|
||||
// this might be a path that comes in from another operating system
|
||||
let mut index: usize = 0;
|
||||
|
||||
if let Some(unix_index) = filename.rfind("/") {
|
||||
if let Some(unix_index) = filename.rfind('/') {
|
||||
index = unix_index + 1;
|
||||
}
|
||||
if let Some(win_index) = filename.rfind("\\") {
|
||||
if let Some(win_index) = filename.rfind('\\') {
|
||||
index = max(index, win_index + 1);
|
||||
}
|
||||
if index >= filename.len() {
|
||||
@@ -439,7 +439,7 @@ fn get_safe_basename(filename: &str) -> String {
|
||||
|
||||
pub fn dc_derive_safe_stem_ext(filename: &str) -> (String, String) {
|
||||
let basename = get_safe_basename(&filename);
|
||||
let (mut stem, mut ext) = if let Some(index) = basename.rfind(".") {
|
||||
let (mut stem, mut ext) = if let Some(index) = basename.rfind('.') {
|
||||
(
|
||||
basename[0..index].to_string(),
|
||||
basename[index..].to_string(),
|
||||
|
||||
10
src/e2ee.rs
10
src/e2ee.rs
@@ -532,7 +532,7 @@ fn decrypt_if_autocrypt_message(
|
||||
// XXX better return parsed headers so that upstream
|
||||
// does not need to dive into mmime-stuff again.
|
||||
unsafe {
|
||||
if (*ret_gossip_headers).is_null() && ret_valid_signatures.len() > 0 {
|
||||
if (*ret_gossip_headers).is_null() && !ret_valid_signatures.is_empty() {
|
||||
let mut dummy: libc::size_t = 0;
|
||||
let mut test: *mut mailimf_fields = ptr::null_mut();
|
||||
if mailimf_envelope_and_optional_fields_parse(
|
||||
@@ -685,12 +685,12 @@ fn contains_report(mime: *mut Mailmime) -> bool {
|
||||
/// If this succeeds you are also guaranteed that the
|
||||
/// [Config::ConfiguredAddr] is configured, this address is returned.
|
||||
pub fn ensure_secret_key_exists(context: &Context) -> Result<String> {
|
||||
let self_addr = context
|
||||
.get_config(Config::ConfiguredAddr)
|
||||
.ok_or(format_err!(concat!(
|
||||
let self_addr = context.get_config(Config::ConfiguredAddr).ok_or_else(|| {
|
||||
format_err!(concat!(
|
||||
"Failed to get self address, ",
|
||||
"cannot ensure secret key if not configured."
|
||||
)))?;
|
||||
))
|
||||
})?;
|
||||
load_or_generate_self_public_key(context, &self_addr)?;
|
||||
Ok(self_addr)
|
||||
}
|
||||
|
||||
34
src/imap.rs
34
src/imap.rs
@@ -331,7 +331,7 @@ struct ImapConfig {
|
||||
|
||||
impl Default for ImapConfig {
|
||||
fn default() -> Self {
|
||||
let cfg = ImapConfig {
|
||||
ImapConfig {
|
||||
addr: "".into(),
|
||||
imap_server: "".into(),
|
||||
imap_port: 0,
|
||||
@@ -346,9 +346,7 @@ impl Default for ImapConfig {
|
||||
has_xlist: false,
|
||||
imap_delimiter: '.',
|
||||
watch_folder: None,
|
||||
};
|
||||
|
||||
cfg
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -935,22 +933,14 @@ impl Imap {
|
||||
let msg = &msgs[0];
|
||||
|
||||
// XXX put flags into a set and pass them to dc_receive_imf
|
||||
let is_deleted = msg
|
||||
.flags()
|
||||
.iter()
|
||||
.find(|flag| match flag {
|
||||
imap::types::Flag::Deleted => true,
|
||||
_ => false,
|
||||
})
|
||||
.is_some();
|
||||
let is_seen = msg
|
||||
.flags()
|
||||
.iter()
|
||||
.find(|flag| match flag {
|
||||
imap::types::Flag::Seen => true,
|
||||
_ => false,
|
||||
})
|
||||
.is_some();
|
||||
let is_deleted = msg.flags().iter().any(|flag| match flag {
|
||||
imap::types::Flag::Deleted => true,
|
||||
_ => false,
|
||||
});
|
||||
let is_seen = msg.flags().iter().any(|flag| match flag {
|
||||
imap::types::Flag::Seen => true,
|
||||
_ => false,
|
||||
});
|
||||
|
||||
let flags = if is_seen { DC_IMAP_SEEN } else { 0 };
|
||||
|
||||
@@ -1218,7 +1208,7 @@ impl Imap {
|
||||
);
|
||||
}
|
||||
}
|
||||
return true; // we tried once, that's probably enough for setting flag
|
||||
true // we tried once, that's probably enough for setting flag
|
||||
} else {
|
||||
unreachable!();
|
||||
}
|
||||
@@ -1300,7 +1290,7 @@ impl Imap {
|
||||
let remote_message_id =
|
||||
prefetch_get_message_id(msgs.first().unwrap()).unwrap_or_default();
|
||||
|
||||
if remote_message_id != message_id.as_ref() {
|
||||
if remote_message_id != message_id {
|
||||
warn!(
|
||||
context,
|
||||
"Cannot delete on IMAP, {}: remote message-id '{}' != '{}'",
|
||||
|
||||
@@ -474,7 +474,7 @@ fn import_backup(context: &Context, backup_to_import: impl AsRef<Path>) -> Resul
|
||||
!dc_is_configured(context),
|
||||
"Cannot import backups to accounts in use."
|
||||
);
|
||||
&context.sql.close(&context);
|
||||
context.sql.close(&context);
|
||||
dc_delete_file(context, context.get_dbfile());
|
||||
ensure!(
|
||||
!dc_file_exist(context, context.get_dbfile()),
|
||||
@@ -511,9 +511,7 @@ fn import_backup(context: &Context, backup_to_import: impl AsRef<Path>) -> Resul
|
||||
Ok((name, blob))
|
||||
},
|
||||
|files| {
|
||||
let mut processed_files_cnt = 0;
|
||||
|
||||
for file in files {
|
||||
for (processed_files_cnt, file) in files.enumerate() {
|
||||
let (file_name, file_blob) = file?;
|
||||
if context
|
||||
.running_state
|
||||
@@ -524,7 +522,6 @@ fn import_backup(context: &Context, backup_to_import: impl AsRef<Path>) -> Resul
|
||||
{
|
||||
bail!("received stop signal");
|
||||
}
|
||||
processed_files_cnt += 1;
|
||||
let mut permille = processed_files_cnt * 1000 / total_files_cnt;
|
||||
if permille < 10 {
|
||||
permille = 10
|
||||
@@ -804,7 +801,7 @@ fn import_self_keys(context: &Context, dir: impl AsRef<Path>) -> Result<()> {
|
||||
"No private keys found in \"{}\".",
|
||||
dir_name
|
||||
);
|
||||
return Ok(());
|
||||
Ok(())
|
||||
} else {
|
||||
bail!("Import: Cannot open directory \"{}\".", dir_name);
|
||||
}
|
||||
|
||||
23
src/job.rs
23
src/job.rs
@@ -142,7 +142,7 @@ impl Job {
|
||||
if let Ok(body) = dc_read_file(context, filename) {
|
||||
if let Some(recipients) = self.param.get(Param::Recipients) {
|
||||
let recipients_list = recipients
|
||||
.split("\x1e")
|
||||
.split('\x1e')
|
||||
.filter_map(|addr| match lettre::EmailAddress::new(addr.to_string()) {
|
||||
Ok(addr) => Some(addr),
|
||||
Err(err) => {
|
||||
@@ -626,13 +626,13 @@ pub fn job_send_msg(context: &Context, msg_id: u32) -> Result<(), Error> {
|
||||
mimefactory.msg.param.get_int(Param::GuranteeE2ee),
|
||||
);
|
||||
}
|
||||
if context.get_config_bool(Config::BccSelf) {
|
||||
if !vec_contains_lowercase(&mimefactory.recipients_addr, &mimefactory.from_addr) {
|
||||
mimefactory.recipients_names.push("".to_string());
|
||||
mimefactory
|
||||
.recipients_addr
|
||||
.push(mimefactory.from_addr.to_string());
|
||||
}
|
||||
if context.get_config_bool(Config::BccSelf)
|
||||
&& !vec_contains_lowercase(&mimefactory.recipients_addr, &mimefactory.from_addr)
|
||||
{
|
||||
mimefactory.recipients_names.push("".to_string());
|
||||
mimefactory
|
||||
.recipients_addr
|
||||
.push(mimefactory.from_addr.to_string());
|
||||
}
|
||||
|
||||
if mimefactory.recipients_addr.is_empty() {
|
||||
@@ -764,13 +764,13 @@ fn job_perform(context: &Context, thread: Thread, probe_network: bool) {
|
||||
// - they can be re-executed one time AT_ONCE, but they are not save in the database for later execution
|
||||
if Action::ConfigureImap == job.action || Action::ImexImap == job.action {
|
||||
job_kill_action(context, job.action);
|
||||
&context
|
||||
context
|
||||
.sentbox_thread
|
||||
.clone()
|
||||
.read()
|
||||
.unwrap()
|
||||
.suspend(context);
|
||||
&context
|
||||
context
|
||||
.mvbox_thread
|
||||
.clone()
|
||||
.read()
|
||||
@@ -895,8 +895,7 @@ fn job_perform(context: &Context, thread: Thread, probe_network: bool) {
|
||||
#[allow(non_snake_case)]
|
||||
fn get_backoff_time_offset(c_tries: libc::c_int) -> i64 {
|
||||
// results in ~3 weeks for the last backoff timespan
|
||||
let mut N = 2_i32.pow((c_tries - 1) as u32);
|
||||
N = N * 60;
|
||||
let N = 2_i32.pow((c_tries - 1) as u32) * 60;
|
||||
let mut rng = thread_rng();
|
||||
let n: i32 = rng.gen();
|
||||
let mut seconds = n % (N + 1);
|
||||
|
||||
@@ -218,10 +218,10 @@ impl Key {
|
||||
let file_content = self.to_asc(None).into_bytes();
|
||||
|
||||
if dc_write_file(context, &file, &file_content) {
|
||||
return true;
|
||||
true
|
||||
} else {
|
||||
error!(context, "Cannot write key to {}", file.as_ref().display());
|
||||
return false;
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ impl Kml {
|
||||
|
||||
pub fn parse(context: &Context, content: impl AsRef<str>) -> Result<Self, Error> {
|
||||
ensure!(
|
||||
content.as_ref().len() <= (1 * 1024 * 1024),
|
||||
content.as_ref().len() <= (1024 * 1024),
|
||||
"A kml-files with {} bytes is larger than reasonably expected.",
|
||||
content.as_ref().len()
|
||||
);
|
||||
@@ -359,7 +359,7 @@ pub fn get_range(
|
||||
}
|
||||
|
||||
fn is_marker(txt: &str) -> bool {
|
||||
txt.len() == 1 && txt.chars().next().unwrap() != ' '
|
||||
txt.len() == 1 && !txt.starts_with(' ')
|
||||
}
|
||||
|
||||
pub fn delete_all(context: &Context) -> Result<(), Error> {
|
||||
|
||||
@@ -494,12 +494,10 @@ impl Lot {
|
||||
} else {
|
||||
self.text1 = None;
|
||||
}
|
||||
} else if let Some(contact) = contact {
|
||||
self.text1 = Some(contact.get_first_name().into());
|
||||
} else {
|
||||
if let Some(contact) = contact {
|
||||
self.text1 = Some(contact.get_first_name().into());
|
||||
} else {
|
||||
self.text1 = None;
|
||||
}
|
||||
self.text1 = None;
|
||||
}
|
||||
self.text1_meaning = Meaning::Text1Username;
|
||||
}
|
||||
@@ -618,9 +616,8 @@ pub fn get_msg_info(context: &Context, msg_id: u32) -> String {
|
||||
}
|
||||
|
||||
ret += "\n";
|
||||
match msg.param.get(Param::Error) {
|
||||
Some(err) => ret += &format!("Error: {}", err),
|
||||
_ => {}
|
||||
if let Some(err) = msg.param.get(Param::Error) {
|
||||
ret += &format!("Error: {}", err)
|
||||
}
|
||||
|
||||
if let Some(path) = msg.get_file(context) {
|
||||
@@ -688,7 +685,7 @@ pub fn get_mime_headers(context: &Context, msg_id: u32) -> Option<String> {
|
||||
}
|
||||
|
||||
pub fn delete_msgs(context: &Context, msg_ids: &[u32]) {
|
||||
for msg_id in msg_ids.into_iter() {
|
||||
for msg_id in msg_ids.iter() {
|
||||
update_msg_chat_id(context, *msg_id, DC_CHAT_ID_TRASH);
|
||||
job_add(
|
||||
context,
|
||||
@@ -728,7 +725,7 @@ pub fn markseen_msgs(context: &Context, msg_ids: &[u32]) -> bool {
|
||||
"SELECT m.state, c.blocked FROM msgs m LEFT JOIN chats c ON c.id=m.chat_id WHERE m.id=? AND m.chat_id>9",
|
||||
|mut stmt, _| {
|
||||
let mut res = Vec::with_capacity(msg_ids.len());
|
||||
for id in msg_ids.into_iter() {
|
||||
for id in msg_ids.iter() {
|
||||
let query_res = stmt.query_row(params![*id as i32], |row| {
|
||||
Ok((row.get::<_, MessageState>(0)?, row.get::<_, Option<Blocked>>(1)?.unwrap_or_default()))
|
||||
});
|
||||
@@ -798,7 +795,7 @@ pub fn star_msgs(context: &Context, msg_ids: &[u32], star: bool) -> bool {
|
||||
context
|
||||
.sql
|
||||
.prepare("UPDATE msgs SET starred=? WHERE id=?;", |mut stmt, _| {
|
||||
for msg_id in msg_ids.into_iter() {
|
||||
for msg_id in msg_ids.iter() {
|
||||
stmt.execute(params![star as i32, *msg_id as i32])?;
|
||||
}
|
||||
Ok(())
|
||||
@@ -837,7 +834,7 @@ pub fn get_summarytext_by_raw(
|
||||
} else {
|
||||
None
|
||||
}
|
||||
.unwrap_or("ErrFileName".to_string());
|
||||
.unwrap_or_else(|| "ErrFileName".to_string());
|
||||
|
||||
let label = context.stock_str(if viewtype == Viewtype::Audio {
|
||||
StockMessage::Audio
|
||||
|
||||
@@ -382,15 +382,8 @@ impl<'a> MimeFactory<'a> {
|
||||
&fingerprint,
|
||||
);
|
||||
}
|
||||
match msg.param.get(Param::Arg4) {
|
||||
Some(id) => {
|
||||
wrapmime::new_custom_field(
|
||||
imf_fields,
|
||||
"Secure-Join-Group",
|
||||
&id,
|
||||
);
|
||||
}
|
||||
None => {}
|
||||
if let Some(id) = msg.param.get(Param::Arg4) {
|
||||
wrapmime::new_custom_field(imf_fields, "Secure-Join-Group", &id);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -640,17 +633,18 @@ impl<'a> MimeFactory<'a> {
|
||||
let aheader = encrypt_helper.get_aheader().to_string();
|
||||
wrapmime::new_custom_field(imffields_unprotected, "Autocrypt", &aheader);
|
||||
}
|
||||
let mut finalized = false;
|
||||
if force_plaintext == 0 {
|
||||
finalized = encrypt_helper.try_encrypt(
|
||||
let finalized = if force_plaintext == 0 {
|
||||
encrypt_helper.try_encrypt(
|
||||
self,
|
||||
e2ee_guaranteed,
|
||||
min_verified,
|
||||
do_gossip,
|
||||
message,
|
||||
imffields_unprotected,
|
||||
)?;
|
||||
}
|
||||
)?
|
||||
} else {
|
||||
false
|
||||
};
|
||||
if !finalized {
|
||||
self.finalize_mime_message(message, false, false)?;
|
||||
}
|
||||
@@ -911,7 +905,7 @@ fn build_body_file(
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn vec_contains_lowercase(vec: &Vec<String>, part: &str) -> bool {
|
||||
pub(crate) fn vec_contains_lowercase(vec: &[String], part: &str) -> bool {
|
||||
let partlc = part.to_lowercase();
|
||||
for cur in vec.iter() {
|
||||
if cur.to_lowercase() == partlc {
|
||||
|
||||
@@ -207,14 +207,8 @@ pub fn dc_get_oauth2_addr(
|
||||
addr: impl AsRef<str>,
|
||||
code: impl AsRef<str>,
|
||||
) -> Option<String> {
|
||||
let oauth2 = Oauth2::from_address(addr.as_ref());
|
||||
if oauth2.is_none() {
|
||||
return None;
|
||||
}
|
||||
let oauth2 = oauth2.unwrap();
|
||||
if oauth2.get_userinfo.is_none() {
|
||||
return None;
|
||||
}
|
||||
let oauth2 = Oauth2::from_address(addr.as_ref())?;
|
||||
oauth2.get_userinfo?;
|
||||
|
||||
if let Some(access_token) =
|
||||
dc_get_oauth2_access_token(context, addr.as_ref(), code.as_ref(), false)
|
||||
|
||||
58
src/param.rs
58
src/param.rs
@@ -12,65 +12,65 @@ use crate::error;
|
||||
#[repr(u8)]
|
||||
pub enum Param {
|
||||
/// For messages and jobs
|
||||
File = 'f' as u8,
|
||||
File = b'f',
|
||||
/// For Messages
|
||||
Width = 'w' as u8,
|
||||
Width = b'w',
|
||||
/// For Messages
|
||||
Height = 'h' as u8,
|
||||
Height = b'h',
|
||||
/// For Messages
|
||||
Duration = 'd' as u8,
|
||||
Duration = b'd',
|
||||
/// For Messages
|
||||
MimeType = 'm' as u8,
|
||||
MimeType = b'm',
|
||||
/// For Messages: message is encryoted, outgoing: guarantee E2EE or the message is not send
|
||||
GuranteeE2ee = 'c' as u8,
|
||||
GuranteeE2ee = b'c',
|
||||
/// For Messages: decrypted with validation errors or without mutual set, if neither
|
||||
/// 'c' nor 'e' are preset, the messages is only transport encrypted.
|
||||
ErroneousE2ee = 'e' as u8,
|
||||
ErroneousE2ee = b'e',
|
||||
/// For Messages: force unencrypted message, either `ForcePlaintext::AddAutocryptHeader` (1),
|
||||
/// `ForcePlaintext::NoAutocryptHeader` (2) or 0.
|
||||
ForcePlaintext = 'u' as u8,
|
||||
ForcePlaintext = b'u',
|
||||
/// For Messages
|
||||
WantsMdn = 'r' as u8,
|
||||
WantsMdn = b'r',
|
||||
/// For Messages
|
||||
Forwarded = 'a' as u8,
|
||||
Forwarded = b'a',
|
||||
/// For Messages
|
||||
Cmd = 'S' as u8,
|
||||
Cmd = b'S',
|
||||
/// For Messages
|
||||
Arg = 'E' as u8,
|
||||
Arg = b'E',
|
||||
/// For Messages
|
||||
Arg2 = 'F' as u8,
|
||||
Arg2 = b'F',
|
||||
/// For Messages
|
||||
Arg3 = 'G' as u8,
|
||||
Arg3 = b'G',
|
||||
/// For Messages
|
||||
Arg4 = 'H' as u8,
|
||||
Arg4 = b'H',
|
||||
/// For Messages
|
||||
Error = 'L' as u8,
|
||||
Error = b'L',
|
||||
/// For Messages: space-separated list of messaged IDs of forwarded copies.
|
||||
PrepForwards = 'P' as u8,
|
||||
PrepForwards = b'P',
|
||||
/// For Jobs
|
||||
SetLatitude = 'l' as u8,
|
||||
SetLatitude = b'l',
|
||||
/// For Jobs
|
||||
SetLongitude = 'n' as u8,
|
||||
SetLongitude = b'n',
|
||||
/// For Jobs
|
||||
ServerFolder = 'Z' as u8,
|
||||
ServerFolder = b'Z',
|
||||
/// For Jobs
|
||||
ServerUid = 'z' as u8,
|
||||
ServerUid = b'z',
|
||||
/// For Jobs
|
||||
AlsoMove = 'M' as u8,
|
||||
AlsoMove = b'M',
|
||||
/// For Jobs: space-separated list of message recipients
|
||||
Recipients = 'R' as u8,
|
||||
Recipients = b'R',
|
||||
// For Groups
|
||||
Unpromoted = 'U' as u8,
|
||||
Unpromoted = b'U',
|
||||
// For Groups and Contacts
|
||||
ProfileImage = 'i' as u8,
|
||||
ProfileImage = b'i',
|
||||
// For Chats
|
||||
Selftalk = 'K' as u8,
|
||||
Selftalk = b'K',
|
||||
// For QR
|
||||
Auth = 's' as u8,
|
||||
Auth = b's',
|
||||
// For QR
|
||||
GroupId = 'x' as u8,
|
||||
GroupId = b'x',
|
||||
// For QR
|
||||
GroupName = 'g' as u8,
|
||||
GroupName = b'g',
|
||||
}
|
||||
|
||||
/// Possible values for `Param::ForcePlaintext`.
|
||||
|
||||
@@ -472,7 +472,7 @@ mod tests {
|
||||
"failed to save to db"
|
||||
);
|
||||
|
||||
let peerstate_new = Peerstate::from_addr(&ctx.ctx, &ctx.ctx.sql, addr.into())
|
||||
let peerstate_new = Peerstate::from_addr(&ctx.ctx, &ctx.ctx.sql, addr)
|
||||
.expect("failed to load peerstate from db");
|
||||
|
||||
// clear to_save, as that is not persissted
|
||||
@@ -555,7 +555,7 @@ mod tests {
|
||||
"failed to save"
|
||||
);
|
||||
|
||||
let peerstate_new = Peerstate::from_addr(&ctx.ctx, &ctx.ctx.sql, addr.into())
|
||||
let peerstate_new = Peerstate::from_addr(&ctx.ctx, &ctx.ctx.sql, addr)
|
||||
.expect("failed to load peerstate from db");
|
||||
|
||||
// clear to_save, as that is not persissted
|
||||
|
||||
@@ -43,7 +43,7 @@ pub unsafe fn dc_split_armored_data(
|
||||
if !buf.is_null() {
|
||||
dc_remove_cr_chars(buf);
|
||||
while 0 != *p1 {
|
||||
if *p1 as libc::c_int == '\n' as i32 {
|
||||
if i32::from(*p1) == '\n' as i32 {
|
||||
*line.offset(line_chars as isize) = 0i32 as libc::c_char;
|
||||
if headerline.is_null() {
|
||||
dc_trim(line);
|
||||
@@ -69,7 +69,7 @@ pub unsafe fn dc_split_armored_data(
|
||||
} else {
|
||||
p2 = strchr(line, ':' as i32);
|
||||
if p2.is_null() {
|
||||
*line.offset(line_chars as isize) = '\n' as i32 as libc::c_char;
|
||||
*line.add(line_chars) = '\n' as i32 as libc::c_char;
|
||||
base64 = line;
|
||||
break;
|
||||
} else {
|
||||
@@ -189,7 +189,7 @@ pub fn dc_pgp_pk_encrypt(
|
||||
let lit_msg = Message::new_literal_bytes("", plain);
|
||||
let pkeys: Vec<&SignedPublicKey> = public_keys_for_encryption
|
||||
.keys()
|
||||
.into_iter()
|
||||
.iter()
|
||||
.filter_map(|key| {
|
||||
let k: &Key = &key;
|
||||
k.try_into().ok()
|
||||
|
||||
@@ -696,7 +696,7 @@ fn encrypted_and_signed(mimeparser: &MimeParser, expected_fingerprint: impl AsRe
|
||||
if !mimeparser.encrypted {
|
||||
warn!(mimeparser.context, "Message not encrypted.",);
|
||||
false
|
||||
} else if mimeparser.signatures.len() <= 0 {
|
||||
} else if mimeparser.signatures.is_empty() {
|
||||
warn!(mimeparser.context, "Message not signed.",);
|
||||
false
|
||||
} else if expected_fingerprint.as_ref().is_empty() {
|
||||
|
||||
@@ -150,7 +150,7 @@ impl Smtp {
|
||||
message_len, recipients_display
|
||||
)));
|
||||
self.transport_connected = true;
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
Err(err) => {
|
||||
bail!("SMTP failed len={}: error: {}", message_len, err);
|
||||
|
||||
12
src/sql.rs
12
src/sql.rs
@@ -224,7 +224,7 @@ impl Sql {
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => {
|
||||
error!(context, "set_config(): Cannot change value. {:?}", &err);
|
||||
Err(err.into())
|
||||
Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1148,12 +1148,8 @@ mod test {
|
||||
maybe_add_file(&mut files, "$BLOBDIR/world.txt");
|
||||
maybe_add_file(&mut files, "world2.txt");
|
||||
|
||||
assert!(is_file_in_use(&mut files, None, "hello"));
|
||||
assert!(!is_file_in_use(&mut files, Some(".txt"), "hello"));
|
||||
assert!(is_file_in_use(
|
||||
&mut files,
|
||||
Some("-suffix"),
|
||||
"world.txt-suffix"
|
||||
));
|
||||
assert!(is_file_in_use(&files, None, "hello"));
|
||||
assert!(!is_file_in_use(&files, Some(".txt"), "hello"));
|
||||
assert!(is_file_in_use(&files, Some("-suffix"), "world.txt-suffix"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,9 +351,7 @@ mod tests {
|
||||
let contact_id = {
|
||||
Contact::create(&t.ctx, "Alice", "alice@example.com")
|
||||
.expect("Failed to create contact Alice");
|
||||
let id =
|
||||
Contact::create(&t.ctx, "Bob", "bob@example.com").expect("failed to create bob");
|
||||
id
|
||||
Contact::create(&t.ctx, "Bob", "bob@example.com").expect("failed to create bob")
|
||||
};
|
||||
assert_eq!(
|
||||
t.ctx.stock_system_msg(
|
||||
|
||||
@@ -329,7 +329,7 @@ pub fn decode_dt_data(
|
||||
let decoded_data = unsafe { (*mime_data).dt_data.dt_text.dt_data };
|
||||
let decoded_data_bytes = unsafe { (*mime_data).dt_data.dt_text.dt_length };
|
||||
|
||||
if decoded_data.is_null() || decoded_data_bytes <= 0 {
|
||||
if decoded_data.is_null() || decoded_data_bytes == 0 {
|
||||
bail!("No data to decode found");
|
||||
} else {
|
||||
let result = unsafe {
|
||||
|
||||
Reference in New Issue
Block a user