mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
chore: nightly clippy fixes
This commit is contained in:
@@ -131,7 +131,7 @@ async fn on_configure_completed(
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if let Some(provider) = param.provider {
|
if let Some(provider) = param.provider {
|
||||||
if let Some(config_defaults) = &provider.config_defaults {
|
if let Some(config_defaults) = &provider.config_defaults {
|
||||||
for def in config_defaults.iter() {
|
for def in config_defaults {
|
||||||
if !context.config_exists(def.key).await? {
|
if !context.config_exists(def.key).await? {
|
||||||
info!(context, "apply config_defaults {}={}", def.key, def.value);
|
info!(context, "apply config_defaults {}={}", def.key, def.value);
|
||||||
context.set_config(def.key, Some(def.value)).await?;
|
context.set_config(def.key, Some(def.value)).await?;
|
||||||
@@ -318,7 +318,7 @@ async fn configure(ctx: &Context, param: &mut LoginParam) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// respect certificate setting from function parameters
|
// respect certificate setting from function parameters
|
||||||
for mut server in &mut servers {
|
for server in &mut servers {
|
||||||
let certificate_checks = match server.protocol {
|
let certificate_checks = match server.protocol {
|
||||||
Protocol::Imap => param.imap.certificate_checks,
|
Protocol::Imap => param.imap.certificate_checks,
|
||||||
Protocol::Smtp => param.smtp.certificate_checks,
|
Protocol::Smtp => param.smtp.certificate_checks,
|
||||||
@@ -653,7 +653,7 @@ async fn try_smtp_one_param(
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
info!(context, "success: {}", inf);
|
info!(context, "success: {}", inf);
|
||||||
smtp.disconnect().await;
|
smtp.disconnect();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ fn parse_serverparams(in_emailaddr: &str, xml_raw: &str) -> Result<Vec<ServerPar
|
|||||||
let res = moz_ac
|
let res = moz_ac
|
||||||
.incoming_servers
|
.incoming_servers
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(moz_ac.outgoing_servers.into_iter())
|
.chain(moz_ac.outgoing_servers)
|
||||||
.filter_map(|server| {
|
.filter_map(|server| {
|
||||||
let protocol = match server.typ.as_ref() {
|
let protocol = match server.typ.as_ref() {
|
||||||
"imap" => Some(Protocol::Imap),
|
"imap" => Some(Protocol::Imap),
|
||||||
|
|||||||
@@ -545,7 +545,7 @@ async fn next_expiration_timestamp(context: &Context) -> Option<i64> {
|
|||||||
|
|
||||||
ephemeral_timestamp
|
ephemeral_timestamp
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(delete_device_after_timestamp.into_iter())
|
.chain(delete_device_after_timestamp)
|
||||||
.min()
|
.min()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
src/html.rs
16
src/html.rs
@@ -291,7 +291,7 @@ mod tests {
|
|||||||
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,
|
parser.html,
|
||||||
r##"<!DOCTYPE html>
|
r#"<!DOCTYPE html>
|
||||||
<html><head>
|
<html><head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="color-scheme" content="light dark" />
|
<meta name="color-scheme" content="light dark" />
|
||||||
@@ -299,7 +299,7 @@ mod tests {
|
|||||||
This message does not have Content-Type nor Subject.<br/>
|
This message does not have Content-Type nor Subject.<br/>
|
||||||
<br/>
|
<br/>
|
||||||
</body></html>
|
</body></html>
|
||||||
"##
|
"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +310,7 @@ This message does not have Content-Type nor Subject.<br/>
|
|||||||
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,
|
parser.html,
|
||||||
r##"<!DOCTYPE html>
|
r#"<!DOCTYPE html>
|
||||||
<html><head>
|
<html><head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="color-scheme" content="light dark" />
|
<meta name="color-scheme" content="light dark" />
|
||||||
@@ -318,7 +318,7 @@ This message does not have Content-Type nor Subject.<br/>
|
|||||||
message with a non-UTF-8 encoding: äöüßÄÖÜ<br/>
|
message with a non-UTF-8 encoding: äöüßÄÖÜ<br/>
|
||||||
<br/>
|
<br/>
|
||||||
</body></html>
|
</body></html>
|
||||||
"##
|
"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +330,7 @@ message with a non-UTF-8 encoding: äöüßÄÖÜ<br/>
|
|||||||
assert!(parser.plain.unwrap().flowed);
|
assert!(parser.plain.unwrap().flowed);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parser.html,
|
parser.html,
|
||||||
r##"<!DOCTYPE html>
|
r#"<!DOCTYPE html>
|
||||||
<html><head>
|
<html><head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="color-scheme" content="light dark" />
|
<meta name="color-scheme" content="light dark" />
|
||||||
@@ -341,7 +341,7 @@ This line does not end with a space<br/>
|
|||||||
and will be wrapped as usual.<br/>
|
and will be wrapped as usual.<br/>
|
||||||
<br/>
|
<br/>
|
||||||
</body></html>
|
</body></html>
|
||||||
"##
|
"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ and will be wrapped as usual.<br/>
|
|||||||
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,
|
parser.html,
|
||||||
r##"<!DOCTYPE html>
|
r#"<!DOCTYPE html>
|
||||||
<html><head>
|
<html><head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="color-scheme" content="light dark" />
|
<meta name="color-scheme" content="light dark" />
|
||||||
@@ -363,7 +363,7 @@ test some special html-characters as < > and & but also " and &#x
|
|||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
</body></html>
|
</body></html>
|
||||||
"##
|
"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -735,7 +735,7 @@ async fn maybe_send_locations(context: &Context) -> Result<Option<u64>> {
|
|||||||
|
|
||||||
next_event = next_event
|
next_event = next_event
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(u64::try_from(locations_send_until - now).into_iter())
|
.chain(u64::try_from(locations_send_until - now))
|
||||||
.min();
|
.min();
|
||||||
|
|
||||||
if has_locations {
|
if has_locations {
|
||||||
@@ -759,7 +759,7 @@ async fn maybe_send_locations(context: &Context) -> Result<Option<u64>> {
|
|||||||
);
|
);
|
||||||
next_event = next_event
|
next_event = next_event
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(u64::try_from(locations_last_sent + 61 - now).into_iter())
|
.chain(u64::try_from(locations_last_sent + 61 - now))
|
||||||
.min();
|
.min();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -643,7 +643,7 @@ impl MimeMessage {
|
|||||||
.parts
|
.parts
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|part| !part.msg.is_empty() && !part.is_reaction);
|
.find(|part| !part.msg.is_empty() && !part.is_reaction);
|
||||||
if let Some(mut part) = part_with_text {
|
if let Some(part) = part_with_text {
|
||||||
part.msg = format!("{} – {}", subject, part.msg);
|
part.msg = format!("{} – {}", subject, part.msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2062,7 +2062,8 @@ async fn handle_mdn(
|
|||||||
Ok((msg_id, chat_id, msg_state))
|
Ok((msg_id, chat_id, msg_state))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await? else {
|
.await?
|
||||||
|
else {
|
||||||
info!(
|
info!(
|
||||||
context,
|
context,
|
||||||
"Ignoring MDN, found no message with Message-ID {rfc724_mid:?} sent by us in the database.",
|
"Ignoring MDN, found no message with Message-ID {rfc724_mid:?} sent by us in the database.",
|
||||||
@@ -3089,7 +3090,7 @@ CWt6wx7fiLp0qS9RrX75g6Gqw7nfCs6EcBERcIPt7DTe8VStJwf3LWqVwxl4gQl46yhfoqwEO+I=
|
|||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn parse_outlook_html_embedded_image() {
|
async fn parse_outlook_html_embedded_image() {
|
||||||
let context = TestContext::new_alice().await;
|
let context = TestContext::new_alice().await;
|
||||||
let raw = br##"From: Anonymous <anonymous@example.org>
|
let raw = br#"From: Anonymous <anonymous@example.org>
|
||||||
To: Anonymous <anonymous@example.org>
|
To: Anonymous <anonymous@example.org>
|
||||||
Subject: Delta Chat is great stuff!
|
Subject: Delta Chat is great stuff!
|
||||||
Date: Tue, 5 May 2020 01:23:45 +0000
|
Date: Tue, 5 May 2020 01:23:45 +0000
|
||||||
@@ -3144,7 +3145,7 @@ K+TuvC7qOah0WLFhcsXWn2+dDV1bXuAeC769TkqkpHhdXfUHnVgK3Pv7u3rVPT5AMeFUGxRB2dP4
|
|||||||
CWt6wx7fiLp0qS9RrX75g6Gqw7nfCs6EcBERcIPt7DTe8VStJwf3LWqVwxl4gQl46yhfoqwEO+I=
|
CWt6wx7fiLp0qS9RrX75g6Gqw7nfCs6EcBERcIPt7DTe8VStJwf3LWqVwxl4gQl46yhfoqwEO+I=
|
||||||
|
|
||||||
------=_NextPart_000_0003_01D622B3.CA753E60--
|
------=_NextPart_000_0003_01D622B3.CA753E60--
|
||||||
"##;
|
"#;
|
||||||
|
|
||||||
let message = MimeMessage::from_bytes(&context.ctx, &raw[..], None)
|
let message = MimeMessage::from_bytes(&context.ctx, &raw[..], None)
|
||||||
.await
|
.await
|
||||||
@@ -3519,7 +3520,7 @@ On 2020-10-25, Bob wrote:
|
|||||||
|
|
||||||
// A message with a long Message-ID.
|
// A message with a long Message-ID.
|
||||||
// Long message-IDs are generated by Mailjet.
|
// Long message-IDs are generated by Mailjet.
|
||||||
let raw = br###"Date: Thu, 28 Jan 2021 00:26:57 +0000
|
let raw = br"Date: Thu, 28 Jan 2021 00:26:57 +0000
|
||||||
Chat-Version: 1.0\n\
|
Chat-Version: 1.0\n\
|
||||||
Message-ID: <ABCDEFGH.1234567_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA@mailjet.com>
|
Message-ID: <ABCDEFGH.1234567_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA@mailjet.com>
|
||||||
To: Bob <bob@example.org>
|
To: Bob <bob@example.org>
|
||||||
@@ -3527,11 +3528,11 @@ From: Alice <alice@example.org>
|
|||||||
Subject: ...
|
Subject: ...
|
||||||
|
|
||||||
Some quote.
|
Some quote.
|
||||||
"###;
|
";
|
||||||
receive_imf(&t, raw, false).await?;
|
receive_imf(&t, raw, false).await?;
|
||||||
|
|
||||||
// Delta Chat generates In-Reply-To with a starting tab when Message-ID is too long.
|
// Delta Chat generates In-Reply-To with a starting tab when Message-ID is too long.
|
||||||
let raw = br###"In-Reply-To:
|
let raw = br"In-Reply-To:
|
||||||
<ABCDEFGH.1234567_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA@mailjet.com>
|
<ABCDEFGH.1234567_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA@mailjet.com>
|
||||||
Date: Thu, 28 Jan 2021 00:26:57 +0000
|
Date: Thu, 28 Jan 2021 00:26:57 +0000
|
||||||
Chat-Version: 1.0\n\
|
Chat-Version: 1.0\n\
|
||||||
@@ -3543,7 +3544,7 @@ Subject: ...
|
|||||||
> Some quote.
|
> Some quote.
|
||||||
|
|
||||||
Some reply
|
Some reply
|
||||||
"###;
|
";
|
||||||
|
|
||||||
receive_imf(&t, raw, false).await?;
|
receive_imf(&t, raw, false).await?;
|
||||||
|
|
||||||
@@ -3561,7 +3562,7 @@ Some reply
|
|||||||
let alice = TestContext::new_alice().await;
|
let alice = TestContext::new_alice().await;
|
||||||
let bob = TestContext::new_bob().await;
|
let bob = TestContext::new_bob().await;
|
||||||
|
|
||||||
let raw = br###"Date: Thu, 28 Jan 2021 00:26:57 +0000
|
let raw = br"Date: Thu, 28 Jan 2021 00:26:57 +0000
|
||||||
Chat-Version: 1.0\n\
|
Chat-Version: 1.0\n\
|
||||||
Message-ID: <foobarbaz@example.org>
|
Message-ID: <foobarbaz@example.org>
|
||||||
To: Bob <bob@example.org>
|
To: Bob <bob@example.org>
|
||||||
@@ -3570,7 +3571,7 @@ Subject: subject
|
|||||||
Chat-Disposition-Notification-To: alice@example.org
|
Chat-Disposition-Notification-To: alice@example.org
|
||||||
|
|
||||||
Message.
|
Message.
|
||||||
"###;
|
";
|
||||||
|
|
||||||
// Bob receives message.
|
// Bob receives message.
|
||||||
receive_imf(&bob, raw, false).await?;
|
receive_imf(&bob, raw, false).await?;
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ impl PlainText {
|
|||||||
/// The function handles quotes, links, fixed and floating text paragraphs.
|
/// The function handles quotes, links, fixed and floating text paragraphs.
|
||||||
pub fn to_html(&self) -> String {
|
pub fn to_html(&self) -> String {
|
||||||
static LINKIFY_MAIL_RE: Lazy<regex::Regex> =
|
static LINKIFY_MAIL_RE: Lazy<regex::Regex> =
|
||||||
Lazy::new(|| regex::Regex::new(r#"\b([\w.\-+]+@[\w.\-]+)\b"#).unwrap());
|
Lazy::new(|| regex::Regex::new(r"\b([\w.\-+]+@[\w.\-]+)\b").unwrap());
|
||||||
|
|
||||||
static LINKIFY_URL_RE: Lazy<regex::Regex> = Lazy::new(|| {
|
static LINKIFY_URL_RE: Lazy<regex::Regex> = Lazy::new(|| {
|
||||||
regex::Regex::new(r#"\b((http|https|ftp|ftps):[\w.,:;$/@!?&%\-~=#+]+)"#).unwrap()
|
regex::Regex::new(r"\b((http|https|ftp|ftps):[\w.,:;$/@!?&%\-~=#+]+)").unwrap()
|
||||||
});
|
});
|
||||||
|
|
||||||
let lines = split_lines(&self.text);
|
let lines = split_lines(&self.text);
|
||||||
@@ -127,7 +127,7 @@ http://link-at-start-of-line.org
|
|||||||
.to_html();
|
.to_html();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
html,
|
html,
|
||||||
r##"<!DOCTYPE html>
|
r#"<!DOCTYPE html>
|
||||||
<html><head>
|
<html><head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="color-scheme" content="light dark" />
|
<meta name="color-scheme" content="light dark" />
|
||||||
@@ -138,7 +138,7 @@ line with <a href="https://link-mid-of-line.org">https://link-mid-of-line.org</a
|
|||||||
<a href="http://link-at-start-of-line.org">http://link-at-start-of-line.org</a><br/>
|
<a href="http://link-at-start-of-line.org">http://link-at-start-of-line.org</a><br/>
|
||||||
<br/>
|
<br/>
|
||||||
</body></html>
|
</body></html>
|
||||||
"##
|
"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ pub async fn get_provider_by_mx(context: &Context, domain: &str) -> Option<&'sta
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(mx_domains) = resolver.mx_lookup(fqdn).await {
|
if let Ok(mx_domains) = resolver.mx_lookup(fqdn).await {
|
||||||
for (provider_domain, provider) in PROVIDER_DATA.iter() {
|
for (provider_domain, provider) in &*PROVIDER_DATA {
|
||||||
if provider.id != "gmail" {
|
if provider.id != "gmail" {
|
||||||
// MX lookup is limited to Gmail for security reasons
|
// MX lookup is limited to Gmail for security reasons
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -2347,7 +2347,7 @@ async fn add_or_lookup_contacts_by_address_list(
|
|||||||
origin: Origin,
|
origin: Origin,
|
||||||
) -> Result<Vec<ContactId>> {
|
) -> Result<Vec<ContactId>> {
|
||||||
let mut contact_ids = HashSet::new();
|
let mut contact_ids = HashSet::new();
|
||||||
for info in address_list.iter() {
|
for info in address_list {
|
||||||
let addr = &info.addr;
|
let addr = &info.addr;
|
||||||
if !may_be_valid_addr(addr) {
|
if !may_be_valid_addr(addr) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -864,7 +864,7 @@ impl Scheduler {
|
|||||||
|
|
||||||
// Actually shutdown tasks.
|
// Actually shutdown tasks.
|
||||||
let timeout_duration = std::time::Duration::from_secs(30);
|
let timeout_duration = std::time::Duration::from_secs(30);
|
||||||
for b in once(self.inbox).chain(self.oboxes.into_iter()) {
|
for b in once(self.inbox).chain(self.oboxes) {
|
||||||
tokio::time::timeout(timeout_duration, b.handle)
|
tokio::time::timeout(timeout_duration, b.handle)
|
||||||
.await
|
.await
|
||||||
.log_err(context)
|
.log_err(context)
|
||||||
|
|||||||
10
src/smtp.rs
10
src/smtp.rs
@@ -55,7 +55,7 @@ impl Smtp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Disconnect the SMTP transport and drop it entirely.
|
/// Disconnect the SMTP transport and drop it entirely.
|
||||||
pub async fn disconnect(&mut self) {
|
pub fn disconnect(&mut self) {
|
||||||
if let Some(mut transport) = self.transport.take() {
|
if let Some(mut transport) = self.transport.take() {
|
||||||
// Closing connection with a QUIT command may take some time, especially if it's a
|
// Closing connection with a QUIT command may take some time, especially if it's a
|
||||||
// stale connection and an attempt to send the command times out. Send a command in a
|
// stale connection and an attempt to send the command times out. Send a command in a
|
||||||
@@ -88,7 +88,7 @@ impl Smtp {
|
|||||||
pub async fn connect_configured(&mut self, context: &Context) -> Result<()> {
|
pub async fn connect_configured(&mut self, context: &Context) -> Result<()> {
|
||||||
if self.has_maybe_stale_connection() {
|
if self.has_maybe_stale_connection() {
|
||||||
info!(context, "Closing stale connection");
|
info!(context, "Closing stale connection");
|
||||||
self.disconnect().await;
|
self.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.is_connected() {
|
if self.is_connected() {
|
||||||
@@ -465,13 +465,13 @@ pub(crate) async fn smtp_send(
|
|||||||
|
|
||||||
// this clears last_success info
|
// this clears last_success info
|
||||||
info!(context, "Failed to send message over SMTP, disconnecting");
|
info!(context, "Failed to send message over SMTP, disconnecting");
|
||||||
smtp.disconnect().await;
|
smtp.disconnect();
|
||||||
|
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
Err(crate::smtp::send::Error::Envelope(err)) => {
|
Err(crate::smtp::send::Error::Envelope(err)) => {
|
||||||
// Local error, job is invalid, do not retry.
|
// Local error, job is invalid, do not retry.
|
||||||
smtp.disconnect().await;
|
smtp.disconnect();
|
||||||
warn!(context, "SMTP job is invalid: {}", err);
|
warn!(context, "SMTP job is invalid: {}", err);
|
||||||
SendResult::Failure(err)
|
SendResult::Failure(err)
|
||||||
}
|
}
|
||||||
@@ -483,7 +483,7 @@ pub(crate) async fn smtp_send(
|
|||||||
}
|
}
|
||||||
Err(crate::smtp::send::Error::Other(err)) => {
|
Err(crate::smtp::send::Error::Other(err)) => {
|
||||||
// Local error, job is invalid, do not retry.
|
// Local error, job is invalid, do not retry.
|
||||||
smtp.disconnect().await;
|
smtp.disconnect();
|
||||||
warn!(context, "unable to load job: {}", err);
|
warn!(context, "unable to load job: {}", err);
|
||||||
SendResult::Failure(err)
|
SendResult::Failure(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user