diff options
Diffstat (limited to 'src/micropub/mod.rs')
-rw-r--r-- | src/micropub/mod.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/micropub/mod.rs b/src/micropub/mod.rs index f3152d7..8f5ca09 100644 --- a/src/micropub/mod.rs +++ b/src/micropub/mod.rs @@ -1,4 +1,5 @@ use std::convert::Infallible; +use std::fmt::Display; use either::Either; use log::warn; use warp::http::StatusCode; @@ -38,7 +39,7 @@ enum ErrorType { } #[derive(Serialize, Deserialize, Debug)] -struct MicropubError { +pub(crate) struct MicropubError { error: ErrorType, error_description: String } @@ -55,6 +56,15 @@ impl From<StorageError> for MicropubError { } } +impl std::error::Error for MicropubError {} + +impl Display for MicropubError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str("Micropub error: ")?; + f.write_str(&self.error_description) + } +} + impl From<&MicropubError> for StatusCode { fn from(err: &MicropubError) -> Self { use ErrorType::*; @@ -98,6 +108,7 @@ impl MicropubError { impl warp::reject::Reject for MicropubError {} mod post; +pub(crate) use post::normalize_mf2; #[allow(unused_variables)] pub mod media { @@ -197,7 +208,7 @@ mod util { } // TODO actually save the post to the database and schedule post-processing -async fn _post<D: Storage, T: hyper::client::connect::Connect + Clone + Send + Sync + 'static>( +pub(crate) async fn _post<D: Storage, T: hyper::client::connect::Connect + Clone + Send + Sync + 'static>( user: crate::indieauth::User, uid: String, mf2: serde_json::Value, @@ -301,7 +312,8 @@ async fn _post<D: Storage, T: hyper::client::connect::Connect + Clone + Send + S contextually_significant_posts.dedup(); // TODO: Make a stream to fetch all these posts and convert them to MF2 - + drop(http); + todo!() }); |