mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 21:36:29 +03:00
Fix 1.59 clippy warnings
This commit is contained in:
@@ -269,7 +269,6 @@ async fn log_msglist(context: &Context, msglist: &[MsgId]) -> Result<()> {
|
|||||||
|
|
||||||
async fn log_contactlist(context: &Context, contacts: &[u32]) -> Result<()> {
|
async fn log_contactlist(context: &Context, contacts: &[u32]) -> Result<()> {
|
||||||
for contact_id in contacts {
|
for contact_id in contacts {
|
||||||
let line;
|
|
||||||
let mut line2 = "".to_string();
|
let mut line2 = "".to_string();
|
||||||
let contact = Contact::get_by_id(context, *contact_id).await?;
|
let contact = Contact::get_by_id(context, *contact_id).await?;
|
||||||
let name = contact.get_display_name();
|
let name = contact.get_display_name();
|
||||||
@@ -284,21 +283,17 @@ async fn log_contactlist(context: &Context, contacts: &[u32]) -> Result<()> {
|
|||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
};
|
};
|
||||||
line = format!(
|
let line = format!(
|
||||||
"{}{} <{}>",
|
"{}{} <{}>",
|
||||||
if !name.is_empty() {
|
if !name.is_empty() {
|
||||||
&name
|
name
|
||||||
} else {
|
} else {
|
||||||
"<name unset>"
|
"<name unset>"
|
||||||
},
|
},
|
||||||
verified_str,
|
verified_str,
|
||||||
if !addr.is_empty() {
|
if !addr.is_empty() { addr } else { "addr unset" }
|
||||||
&addr
|
|
||||||
} else {
|
|
||||||
"addr unset"
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
let peerstate = Peerstate::from_addr(context, &addr)
|
let peerstate = Peerstate::from_addr(context, addr)
|
||||||
.await
|
.await
|
||||||
.expect("peerstate error");
|
.expect("peerstate error");
|
||||||
if peerstate.is_some() && *contact_id != 1 {
|
if peerstate.is_some() && *contact_id != 1 {
|
||||||
@@ -771,7 +766,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
|
|||||||
chat::set_chat_name(
|
chat::set_chat_name(
|
||||||
&context,
|
&context,
|
||||||
sel_chat.as_ref().unwrap().get_id(),
|
sel_chat.as_ref().unwrap().get_id(),
|
||||||
&format!("{} {}", arg1, arg2).trim(),
|
format!("{} {}", arg1, arg2).trim(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|||||||
@@ -416,7 +416,7 @@ async fn handle_cmd(
|
|||||||
}
|
}
|
||||||
"getqr" | "getbadqr" => {
|
"getqr" | "getbadqr" => {
|
||||||
ctx.start_io().await;
|
ctx.start_io().await;
|
||||||
let group = arg1.parse::<u32>().ok().map(|id| ChatId::new(id));
|
let group = arg1.parse::<u32>().ok().map(ChatId::new);
|
||||||
let mut qr = dc_get_securejoin_qr(&ctx, group).await?;
|
let mut qr = dc_get_securejoin_qr(&ctx, group).await?;
|
||||||
if !qr.is_empty() {
|
if !qr.is_empty() {
|
||||||
if arg0 == "getbadqr" && qr.len() > 40 {
|
if arg0 == "getbadqr" && qr.len() > 40 {
|
||||||
@@ -433,7 +433,7 @@ async fn handle_cmd(
|
|||||||
}
|
}
|
||||||
"getqrsvg" => {
|
"getqrsvg" => {
|
||||||
ctx.start_io().await;
|
ctx.start_io().await;
|
||||||
let group = arg1.parse::<u32>().ok().map(|id| ChatId::new(id));
|
let group = arg1.parse::<u32>().ok().map(ChatId::new);
|
||||||
let file = dirs::home_dir().unwrap_or_default().join("qr.svg");
|
let file = dirs::home_dir().unwrap_or_default().join("qr.svg");
|
||||||
match get_securejoin_qr_svg(&ctx, group).await {
|
match get_securejoin_qr_svg(&ctx, group).await {
|
||||||
Ok(svg) => {
|
Ok(svg) => {
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ impl<'a> BlobObject<'a> {
|
|||||||
|
|
||||||
/// Returns the filename of the blob.
|
/// Returns the filename of the blob.
|
||||||
pub fn as_file_name(&self) -> &str {
|
pub fn as_file_name(&self) -> &str {
|
||||||
self.name.rsplitn(2, '/').next().unwrap()
|
self.name.rsplit('/').next().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The path relative in the blob directory.
|
/// The path relative in the blob directory.
|
||||||
@@ -305,7 +305,7 @@ impl<'a> BlobObject<'a> {
|
|||||||
/// If a blob's filename has an extension, it is always guaranteed
|
/// If a blob's filename has an extension, it is always guaranteed
|
||||||
/// to be lowercase.
|
/// to be lowercase.
|
||||||
pub fn suffix(&self) -> Option<&str> {
|
pub fn suffix(&self) -> Option<&str> {
|
||||||
let ext = self.name.rsplitn(2, '.').next();
|
let ext = self.name.rsplit('.').next();
|
||||||
if ext == Some(&self.name) {
|
if ext == Some(&self.name) {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1160,7 +1160,7 @@ impl Chat {
|
|||||||
/// deltachat, and the data returned is still subject to change.
|
/// deltachat, and the data returned is still subject to change.
|
||||||
pub async fn get_info(&self, context: &Context) -> Result<ChatInfo> {
|
pub async fn get_info(&self, context: &Context) -> Result<ChatInfo> {
|
||||||
let draft = match self.id.get_draft(context).await? {
|
let draft = match self.id.get_draft(context).await? {
|
||||||
Some(message) => message.text.unwrap_or_else(String::new),
|
Some(message) => message.text.unwrap_or_default(),
|
||||||
_ => String::new(),
|
_ => String::new(),
|
||||||
};
|
};
|
||||||
Ok(ChatInfo {
|
Ok(ChatInfo {
|
||||||
|
|||||||
@@ -1179,7 +1179,7 @@ async fn set_block_contact(context: &Context, contact_id: u32, new_blocking: boo
|
|||||||
.sql
|
.sql
|
||||||
.execute(
|
.execute(
|
||||||
"UPDATE contacts SET blocked=? WHERE id=?;",
|
"UPDATE contacts SET blocked=? WHERE id=?;",
|
||||||
paramsv![new_blocking as i32, contact_id as i32],
|
paramsv![i32::from(new_blocking), contact_id as i32],
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|||||||
@@ -1372,7 +1372,7 @@ async fn is_probably_private_reply(
|
|||||||
// should be assigned to the group chat. We restrict this exception to classical emails, as chat-group-messages
|
// should be assigned to the group chat. We restrict this exception to classical emails, as chat-group-messages
|
||||||
// contain a Chat-Group-Id header and can be sorted into the correct chat this way.
|
// contain a Chat-Group-Id header and can be sorted into the correct chat this way.
|
||||||
|
|
||||||
let private_message = to_ids == [DC_CONTACT_ID_SELF].iter().copied().collect::<Vec<u32>>();
|
let private_message = to_ids == [DC_CONTACT_ID_SELF];
|
||||||
if !private_message {
|
if !private_message {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
@@ -1406,7 +1406,7 @@ async fn create_or_lookup_group(
|
|||||||
let grpid = if let Some(grpid) = try_getting_grpid(mime_parser) {
|
let grpid = if let Some(grpid) = try_getting_grpid(mime_parser) {
|
||||||
grpid
|
grpid
|
||||||
} else if allow_creation {
|
} else if allow_creation {
|
||||||
let mut member_ids: Vec<u32> = to_ids.iter().copied().collect();
|
let mut member_ids: Vec<u32> = to_ids.to_vec();
|
||||||
if !member_ids.contains(&(from_id as u32)) {
|
if !member_ids.contains(&(from_id as u32)) {
|
||||||
member_ids.push(from_id as u32);
|
member_ids.push(from_id as u32);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -534,8 +534,8 @@ impl rusqlite::types::ToSql for EmailAddress {
|
|||||||
/// Makes sure that a user input that is not supposed to contain newlines does not contain newlines.
|
/// Makes sure that a user input that is not supposed to contain newlines does not contain newlines.
|
||||||
pub(crate) fn improve_single_line_input(input: &str) -> String {
|
pub(crate) fn improve_single_line_input(input: &str) -> String {
|
||||||
input
|
input
|
||||||
.replace("\n", " ")
|
.replace('\n', " ")
|
||||||
.replace("\r", " ")
|
.replace('\r', " ")
|
||||||
.trim()
|
.trim()
|
||||||
.to_string()
|
.to_string()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -365,7 +365,7 @@ test some special html-characters as < > and & but also " and &#x
|
|||||||
// however, rust multiline-strings use just `\n`;
|
// however, rust multiline-strings use just `\n`;
|
||||||
// therefore, we just remove `\r` before comparison.
|
// therefore, we just remove `\r` before comparison.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parser.html.replace("\r", ""),
|
parser.html.replace('\r', ""),
|
||||||
r##"
|
r##"
|
||||||
<html>
|
<html>
|
||||||
<p>mime-modified <b>set</b>; simplify is always regarded as lossy.</p>
|
<p>mime-modified <b>set</b>; simplify is always regarded as lossy.</p>
|
||||||
@@ -379,7 +379,7 @@ test some special html-characters as < > and & but also " and &#x
|
|||||||
let raw = include_bytes!("../test-data/message/text_alt_html.eml");
|
let raw = include_bytes!("../test-data/message/text_alt_html.eml");
|
||||||
let parser = HtmlMsgParser::from_bytes(&t.ctx, raw).await.unwrap();
|
let parser = HtmlMsgParser::from_bytes(&t.ctx, raw).await.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parser.html.replace("\r", ""), // see comment in test_htmlparse_html()
|
parser.html.replace('\r', ""), // see comment in test_htmlparse_html()
|
||||||
r##"<html>
|
r##"<html>
|
||||||
<p>mime-modified <b>set</b>; simplify is always regarded as lossy.</p>
|
<p>mime-modified <b>set</b>; simplify is always regarded as lossy.</p>
|
||||||
</html>
|
</html>
|
||||||
@@ -394,7 +394,7 @@ test some special html-characters as < > and & but also " and &#x
|
|||||||
let raw = include_bytes!("../test-data/message/text_alt_plain_html.eml");
|
let raw = include_bytes!("../test-data/message/text_alt_plain_html.eml");
|
||||||
let parser = HtmlMsgParser::from_bytes(&t.ctx, raw).await.unwrap();
|
let parser = HtmlMsgParser::from_bytes(&t.ctx, raw).await.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parser.html.replace("\r", ""), // see comment in test_htmlparse_html()
|
parser.html.replace('\r', ""), // see comment in test_htmlparse_html()
|
||||||
r##"<html>
|
r##"<html>
|
||||||
<p>
|
<p>
|
||||||
this is <b>html</b>
|
this is <b>html</b>
|
||||||
|
|||||||
@@ -165,7 +165,6 @@ pub async fn initiate_key_transfer(context: &Context) -> Result<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn do_initiate_key_transfer(context: &Context) -> Result<String> {
|
async fn do_initiate_key_transfer(context: &Context) -> Result<String> {
|
||||||
let mut msg: Message;
|
|
||||||
let setup_code = create_setup_code(context);
|
let setup_code = create_setup_code(context);
|
||||||
/* this may require a keypair to be created. this may take a second ... */
|
/* this may require a keypair to be created. this may take a second ... */
|
||||||
let setup_file_content = render_setup_file(context, &setup_code).await?;
|
let setup_file_content = render_setup_file(context, &setup_code).await?;
|
||||||
@@ -178,8 +177,10 @@ async fn do_initiate_key_transfer(context: &Context) -> Result<String> {
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let chat_id = ChatId::create_for_contact(context, DC_CONTACT_ID_SELF).await?;
|
let chat_id = ChatId::create_for_contact(context, DC_CONTACT_ID_SELF).await?;
|
||||||
msg = Message::default();
|
let mut msg = Message {
|
||||||
msg.viewtype = Viewtype::File;
|
viewtype: Viewtype::File,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
msg.param.set(Param::File, setup_file_blob.as_name());
|
msg.param.set(Param::File, setup_file_blob.as_name());
|
||||||
msg.subject = stock_str::ac_setup_msg_subject(context).await;
|
msg.subject = stock_str::ac_setup_msg_subject(context).await;
|
||||||
msg.param
|
msg.param
|
||||||
@@ -236,7 +237,7 @@ pub async fn render_setup_file(context: &Context, passphrase: &str) -> Result<St
|
|||||||
|
|
||||||
let msg_subj = stock_str::ac_setup_msg_subject(context).await;
|
let msg_subj = stock_str::ac_setup_msg_subject(context).await;
|
||||||
let msg_body = stock_str::ac_setup_msg_body(context).await;
|
let msg_body = stock_str::ac_setup_msg_body(context).await;
|
||||||
let msg_body_html = msg_body.replace("\r", "").replace("\n", "<br>");
|
let msg_body_html = msg_body.replace('\r', "").replace('\n', "<br>");
|
||||||
Ok(format!(
|
Ok(format!(
|
||||||
concat!(
|
concat!(
|
||||||
"<!DOCTYPE html>\r\n",
|
"<!DOCTYPE html>\r\n",
|
||||||
|
|||||||
@@ -297,8 +297,8 @@ pub async fn store_self_keypair(
|
|||||||
.context("failed to clear default")?;
|
.context("failed to clear default")?;
|
||||||
}
|
}
|
||||||
let is_default = match default {
|
let is_default = match default {
|
||||||
KeyPairUse::Default => true as i32,
|
KeyPairUse::Default => i32::from(true),
|
||||||
KeyPairUse::ReadOnly => false as i32,
|
KeyPairUse::ReadOnly => i32::from(false),
|
||||||
};
|
};
|
||||||
|
|
||||||
let addr = keypair.addr.to_string();
|
let addr = keypair.addr.to_string();
|
||||||
|
|||||||
@@ -101,10 +101,10 @@ impl Kml {
|
|||||||
let val = event.unescape_and_decode(reader).unwrap_or_default();
|
let val = event.unescape_and_decode(reader).unwrap_or_default();
|
||||||
|
|
||||||
let val = val
|
let val = val
|
||||||
.replace("\n", "")
|
.replace('\n', "")
|
||||||
.replace("\r", "")
|
.replace('\r', "")
|
||||||
.replace("\t", "")
|
.replace('\t', "")
|
||||||
.replace(" ", "");
|
.replace(' ', "");
|
||||||
|
|
||||||
if self.tag.contains(KmlTag::WHEN) && val.len() >= 19 {
|
if self.tag.contains(KmlTag::WHEN) && val.len() >= 19 {
|
||||||
// YYYY-MM-DDTHH:MM:SSZ
|
// YYYY-MM-DDTHH:MM:SSZ
|
||||||
|
|||||||
@@ -379,10 +379,9 @@ impl Peerstate {
|
|||||||
pub fn peek_key(&self, min_verified: PeerstateVerifiedStatus) -> Option<&SignedPublicKey> {
|
pub fn peek_key(&self, min_verified: PeerstateVerifiedStatus) -> Option<&SignedPublicKey> {
|
||||||
match min_verified {
|
match min_verified {
|
||||||
PeerstateVerifiedStatus::BidirectVerified => self.verified_key.as_ref(),
|
PeerstateVerifiedStatus::BidirectVerified => self.verified_key.as_ref(),
|
||||||
PeerstateVerifiedStatus::Unverified => self
|
PeerstateVerifiedStatus::Unverified => {
|
||||||
.public_key
|
self.public_key.as_ref().or(self.gossip_key.as_ref())
|
||||||
.as_ref()
|
}
|
||||||
.or_else(|| self.gossip_key.as_ref()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ impl PlainText {
|
|||||||
// as <http://example.org> cannot be handled correctly
|
// as <http://example.org> cannot be handled correctly
|
||||||
// (they would become <http://example.org> where the trailing > would become a valid url part).
|
// (they would become <http://example.org> where the trailing > would become a valid url part).
|
||||||
// to avoid double encoding, we escape our html-entities by \r that must not be used in the string elsewhere.
|
// to avoid double encoding, we escape our html-entities by \r that must not be used in the string elsewhere.
|
||||||
let line = line.to_string().replace("\r", "");
|
let line = line.to_string().replace('\r', "");
|
||||||
|
|
||||||
let mut line = LINKIFY_MAIL_RE
|
let mut line = LINKIFY_MAIL_RE
|
||||||
.replace_all(&*line, "\rLTa href=\rQUOTmailto:$1\rQUOT\rGT$1\rLT/a\rGT")
|
.replace_all(&*line, "\rLTa href=\rQUOTmailto:$1\rQUOT\rGT$1\rLT/a\rGT")
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ pub async fn get_provider_info(
|
|||||||
domain: &str,
|
domain: &str,
|
||||||
skip_mx: bool,
|
skip_mx: bool,
|
||||||
) -> Option<&'static Provider> {
|
) -> Option<&'static Provider> {
|
||||||
let domain = domain.rsplitn(2, '@').next()?;
|
let domain = domain.rsplit('@').next()?;
|
||||||
|
|
||||||
if let Some(provider) = get_provider_by_domain(domain) {
|
if let Some(provider) = get_provider_by_domain(domain) {
|
||||||
return Some(provider);
|
return Some(provider);
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result<Qr> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let name = if let Some(encoded_name) = param.get("n") {
|
let name = if let Some(encoded_name) = param.get("n") {
|
||||||
let encoded_name = encoded_name.replace("+", "%20"); // sometimes spaces are encoded as `+`
|
let encoded_name = encoded_name.replace('+', "%20"); // sometimes spaces are encoded as `+`
|
||||||
match percent_decode_str(&encoded_name).decode_utf8() {
|
match percent_decode_str(&encoded_name).decode_utf8() {
|
||||||
Ok(name) => name.to_string(),
|
Ok(name) => name.to_string(),
|
||||||
Err(err) => bail!("Invalid name: {}", err),
|
Err(err) => bail!("Invalid name: {}", err),
|
||||||
@@ -188,7 +188,7 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result<Qr> {
|
|||||||
|
|
||||||
let grpname = if grpid.is_some() {
|
let grpname = if grpid.is_some() {
|
||||||
if let Some(encoded_name) = param.get("g") {
|
if let Some(encoded_name) = param.get("g") {
|
||||||
let encoded_name = encoded_name.replace("+", "%20"); // sometimes spaces are encoded as `+`
|
let encoded_name = encoded_name.replace('+', "%20"); // sometimes spaces are encoded as `+`
|
||||||
match percent_decode_str(&encoded_name).decode_utf8() {
|
match percent_decode_str(&encoded_name).decode_utf8() {
|
||||||
Ok(name) => Some(name.to_string()),
|
Ok(name) => Some(name.to_string()),
|
||||||
Err(err) => bail!("Invalid group name: {}", err),
|
Err(err) => bail!("Invalid group name: {}", err),
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ fn render_message(lines: &[&str], is_cut_at_end: bool) -> String {
|
|||||||
ret += " [...]";
|
ret += " [...]";
|
||||||
}
|
}
|
||||||
// redo escaping done by escape_message_footer_marks()
|
// redo escaping done by escape_message_footer_marks()
|
||||||
ret.replace("\u{200B}", "")
|
ret.replace('\u{200B}', "")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the line contains only whitespace.
|
/// Returns true if the line contains only whitespace.
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ pub(crate) async fn smtp_send(
|
|||||||
// Other enhanced status codes, such as Postfix
|
// Other enhanced status codes, such as Postfix
|
||||||
// "550 5.1.1 <foobar@example.org>: Recipient address rejected: User unknown in local recipient table"
|
// "550 5.1.1 <foobar@example.org>: Recipient address rejected: User unknown in local recipient table"
|
||||||
// are not ignored.
|
// are not ignored.
|
||||||
response.first_word() == Some(&"5.5.0".to_string())
|
response.first_word() == Some("5.5.0")
|
||||||
}
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user