From 48a559ccbf28429f81286911be1a5f912a469435 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Fri, 13 Oct 2023 17:09:51 +0200 Subject: [PATCH] Improve e-mail generation per review. --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/email.rs | 11 +++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6083b9b1e7f..1048278e2d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4014,9 +4014,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "typomania" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad7c8a25a8622dd21e64b158926b92ab4e0fd1f592f53311ab838ce16ba2f51" +checksum = "46927efb3477a5411d9ab9e55e55df6b6df07ded9aa2cdf42da386b15182c61b" dependencies = [ "bitflip", "itertools", diff --git a/Cargo.toml b/Cargo.toml index 1cf8163a80c..c05f357bafa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -95,7 +95,7 @@ tower = "=0.4.13" tower-http = { version = "=0.4.4", features = ["fs", "catch-panic"] } tracing = "=0.1.37" tracing-subscriber = { version = "=0.3.17", features = ["env-filter"] } -typomania = { version = "=0.1.0", default-features = false } +typomania = { version = "=0.1.1", default-features = false } url = "=2.4.1" [dev-dependencies] diff --git a/src/email.rs b/src/email.rs index 62953ea7401..353123d2fed 100644 --- a/src/email.rs +++ b/src/email.rs @@ -98,6 +98,7 @@ or go to https://{domain}/me/pending-invites to manage all of your crate ownersh crate_name: &str, squats: &[typomania::checks::Squat], ) -> AppResult<()> { + let domain = crate::config::domain_name(); let subject = "Possible typosquatting in new crate"; let body = format!( "New crate {crate_name} may be typosquatting one or more other crates.\n @@ -105,13 +106,15 @@ Visit https://{domain}/crates/{crate_name} to see the offending crate.\n \n Specific squat checks that triggered:\n \n -- {squats}\n", - domain = crate::config::domain_name(), +{squats}", squats = squats .iter() - .map(|squat| format!("{squat}")) + .map(|squat| format!( + "- {squat} (https://{domain}/crates/{crate_name})\n", + crate_name = squat.package() + )) .collect::>() - .join("\n- "), + .join(""), ); self.send(email, subject, &body)