diff --git a/plume-models/src/lib.rs b/plume-models/src/lib.rs index 7e424da8..1f39252f 100644 --- a/plume-models/src/lib.rs +++ b/plume-models/src/lib.rs @@ -24,6 +24,7 @@ use heck::ToUpperCamelCase; pub use lettre; pub use lettre::smtp; use once_cell::sync::Lazy; +use plume_common::activity_pub::PreferredUsernameError; use plume_common::activity_pub::{inbox::InboxError, request, sign, PreferredUsername}; use posts::PostEvent; use riker::actors::{channel, ActorSystem, ChannelRef, SystemBuilder}; @@ -175,6 +176,13 @@ impl From for Error { } } +impl From for Error { + fn from(err: PreferredUsernameError) -> Error { + tracing::trace!("{:?}", err); + Error::InvalidValue + } +} + pub type Result = std::result::Result; /// Adds a function to a model, that returns the first @@ -349,13 +357,13 @@ pub enum Fqn { impl Fqn { pub fn new_local(username: String) -> Result { Ok(Self::Local( - PreferredUsername::new(username).map_err(|_| Error::InvalidValue)?, + PreferredUsername::new(username)?, )) } pub fn new_remote(username: String, domain: String) -> Result { Ok(Self::Remote( - PreferredUsername::new(username).map_err(|_| Error::InvalidValue)?, + PreferredUsername::new(username)?, domain, )) }