about summary refs log tree commit diff
path: root/src/micropub/mod.rs
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2022-03-07 11:36:19 +0300
committerVika <vika@fireburn.ru>2022-03-07 11:36:19 +0300
commit95ce885dbc1f8c5c431c7607a054d08da7392867 (patch)
tree2a0687ffb2af5b81a85ee89d6fb7dca8951cc731 /src/micropub/mod.rs
parentf4f75e6e21e014aed06a3dde1474873cbe4fa2c6 (diff)
Port onboarding
Diffstat (limited to 'src/micropub/mod.rs')
-rw-r--r--src/micropub/mod.rs18
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!()
     });