mirror of
https://github.com/chatmail/relay.git
synced 2026-08-12 11:30:52 +00:00
refactor: Apply more lints (#17)
Sets lint rules and applies required changes. Fixes: #16 Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
This commit is contained in:
committed by
GitHub
parent
aab39be662
commit
9eb86b23ce
+36
-3
@@ -1,3 +1,29 @@
|
||||
#![doc = include_str!("../README.md")]
|
||||
#![forbid(unsafe_code)]
|
||||
#![warn(
|
||||
unused,
|
||||
clippy::correctness,
|
||||
missing_debug_implementations,
|
||||
missing_docs,
|
||||
clippy::all,
|
||||
clippy::wildcard_imports,
|
||||
clippy::needless_borrow,
|
||||
clippy::cast_lossless,
|
||||
clippy::unused_async,
|
||||
clippy::explicit_iter_loop,
|
||||
clippy::explicit_into_iter_loop,
|
||||
clippy::cloned_instead_of_copied
|
||||
)]
|
||||
#![cfg_attr(not(test), forbid(clippy::indexing_slicing))]
|
||||
#![cfg_attr(not(test), forbid(clippy::string_slice))]
|
||||
#![allow(
|
||||
clippy::match_bool,
|
||||
clippy::mixed_read_write_in_expression,
|
||||
clippy::bool_assert_comparison,
|
||||
clippy::manual_split_once,
|
||||
clippy::format_push_string,
|
||||
clippy::bool_to_int_with_if
|
||||
)]
|
||||
mod config;
|
||||
pub(crate) mod error;
|
||||
pub(crate) mod inbound;
|
||||
@@ -30,13 +56,20 @@ async fn main() {
|
||||
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() != 3 {
|
||||
eprintln!("Usage: {} <config_file> <mode>", args[0]);
|
||||
eprintln!(
|
||||
"Usage: {} <config_file> <mode>",
|
||||
args.first().unwrap_or(&"filtermail".to_string())
|
||||
);
|
||||
eprintln!(" mode: incoming or outgoing");
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
let config_path = &args[1];
|
||||
let mode = &args[2];
|
||||
let Some(config_path) = args.get(1) else {
|
||||
unreachable!("args length checked above")
|
||||
};
|
||||
let Some(mode) = args.get(2) else {
|
||||
unreachable!("args length checked above")
|
||||
};
|
||||
|
||||
if mode != "incoming" && mode != "outgoing" {
|
||||
eprintln!("Error: mode must be 'incoming' or 'outgoing'");
|
||||
|
||||
@@ -25,7 +25,9 @@ pub fn is_securejoin(mail: &mailparse::ParsedMail) -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
let part = &mail.subparts[0];
|
||||
let Some(part) = &mail.subparts.first() else {
|
||||
return false;
|
||||
};
|
||||
|
||||
// Part must not be multipart
|
||||
if !part.subparts.is_empty() {
|
||||
|
||||
@@ -92,7 +92,10 @@ impl SmtpHandler for OutgoingBeforeQueueHandler {
|
||||
}
|
||||
|
||||
// Allow self-sent Autocrypt Setup Message
|
||||
if envelope.rcpt_to.len() == 1 && envelope.rcpt_to[0] == envelope.mail_from {
|
||||
if envelope.rcpt_to.len() == 1
|
||||
&& let Some(rcpt_to) = envelope.rcpt_to.first()
|
||||
&& *rcpt_to == envelope.mail_from
|
||||
{
|
||||
let subject = message
|
||||
.headers
|
||||
.get_first_value("Subject")
|
||||
|
||||
Reference in New Issue
Block a user