diff --git a/plume-models/src/lib.rs b/plume-models/src/lib.rs index 83c2b5a3..7e424da8 100644 --- a/plume-models/src/lib.rs +++ b/plume-models/src/lib.rs @@ -20,6 +20,7 @@ use activitystreams::iri_string; use diesel::backend::Backend; use diesel::sql_types::Text; use diesel::types::{FromSql, ToSql}; +use heck::ToUpperCamelCase; pub use lettre; pub use lettre::smtp; use once_cell::sync::Lazy; @@ -358,6 +359,21 @@ impl Fqn { domain, )) } + + pub fn make_local_string(base: &str) -> String { + base.to_upper_camel_case() + .chars() + .filter(|c| c.is_ascii_alphanumeric()) + .collect() + } + + pub fn make_local(base: &str) -> Result { + Self::new_local(Self::make_local_string(base)) + } + + pub fn make_remote(base: &str, domain: String) -> Result { + Self::new_remote(Self::make_local_string(base), domain) + } } impl From<&Fqn> for String {