mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-22 03:21:01 +00:00
Define From<PreferredUsernameError> for Error
This commit is contained in:
parent
39cd4f830d
commit
9bd8f5272f
1 changed files with 10 additions and 2 deletions
|
@ -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<request::Error> for Error {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<PreferredUsernameError> for Error {
|
||||
fn from(err: PreferredUsernameError) -> Error {
|
||||
tracing::trace!("{:?}", err);
|
||||
Error::InvalidValue
|
||||
}
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
/// 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<Self> {
|
||||
Ok(Self::Local(
|
||||
PreferredUsername::new(username).map_err(|_| Error::InvalidValue)?,
|
||||
PreferredUsername::new(username)?,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn new_remote(username: String, domain: String) -> Result<Self> {
|
||||
Ok(Self::Remote(
|
||||
PreferredUsername::new(username).map_err(|_| Error::InvalidValue)?,
|
||||
PreferredUsername::new(username)?,
|
||||
domain,
|
||||
))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue