diff --git a/Cargo.lock b/Cargo.lock index 19000f3..d2d71a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -906,7 +906,6 @@ dependencies = [ "html-escape", "mail-send", "md-5", - "rand", "sailfish", "serde", "serde-inline-default", diff --git a/Cargo.toml b/Cargo.toml index f39aa18..3145b28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ edition = "2021" # core tracing = "0.1" tracing-subscriber = "0.3" -rand = "0.8" md-5 = "0.10" toml = "0.8" chrono = { version = "0.4", features = ["serde"] } diff --git a/src/model.rs b/src/model.rs index 462530b..9a78e03 100644 --- a/src/model.rs +++ b/src/model.rs @@ -1,5 +1,4 @@ use md5::{Md5, Digest}; -use rand::{distributions::Alphanumeric, Rng}; use serde::{Serialize, Deserialize}; use chrono::{DateTime, Utc}; use sqlx::Row; @@ -52,7 +51,7 @@ pub struct PageView { impl From<&Page> for PageView { fn from(page: &Page) -> Self { let mut hasher = Md5::new(); - hasher.update(page.contact.as_deref().unwrap_or(&random_string(36)).as_bytes()); + hasher.update(page.contact.as_deref().unwrap_or(&format!("{} - {}", page.body, page.timestamp)).as_bytes()); let avatar = format!("{:x}", hasher.finalize()); let url = match page.contact.as_deref() { @@ -127,11 +126,3 @@ fn _non_empty_string(input: String) -> Option { false => Some(input), } } - -fn random_string(len: usize) -> String { - rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(len) - .map(char::from) - .collect() -}