about summary refs log tree commit diff
path: root/src/micropub/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/micropub/mod.rs')
-rw-r--r--src/micropub/mod.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/micropub/mod.rs b/src/micropub/mod.rs
index 719fbf0..8505ae5 100644
--- a/src/micropub/mod.rs
+++ b/src/micropub/mod.rs
@@ -1,5 +1,6 @@
 use std::collections::HashMap;
 use url::Url;
+use util::NormalizedPost;
 use std::sync::Arc;
 
 use crate::database::{MicropubChannel, Storage, StorageError};
@@ -39,7 +40,7 @@ impl From<StorageError> for MicropubError {
     }
 }
 
-mod util;
+pub(crate) mod util;
 pub(crate) use util::normalize_mf2;
 
 #[derive(Debug)]
@@ -591,8 +592,8 @@ pub(crate) async fn post<D: Storage + 'static, A: AuthBackend>(
             Err(err) => err.into_response(),
         },
         Ok(PostBody::MF2(mf2)) => {
-            let (uid, mf2) = normalize_mf2(mf2, &user);
-            match _post(&user, uid, mf2, db, http, jobset).await {
+            let NormalizedPost { id, post } = normalize_mf2(mf2, &user);
+            match _post(&user, id, post, db, http, jobset).await {
                 Ok(response) => response,
                 Err(err) => err.into_response(),
             }
@@ -764,7 +765,7 @@ impl MicropubQuery {
 mod tests {
     use std::sync::Arc;
 
-    use crate::{database::Storage, micropub::MicropubError};
+    use crate::{database::Storage, micropub::{util::NormalizedPost, MicropubError}};
     use bytes::Bytes;
     use futures::StreamExt;
     use serde_json::json;
@@ -831,10 +832,10 @@ mod tests {
             scope: Scopes::new(vec![Scope::Profile]),
             iat: None, exp: None
         };
-        let (uid, mf2) = super::normalize_mf2(post, &user);
+        let NormalizedPost { id, post } = super::normalize_mf2(post, &user);
 
         let err = super::_post(
-            &user, uid, mf2, db.clone(),
+            &user, id, post, db.clone(),
             reqwest_middleware::ClientWithMiddleware::new(
                 reqwest::Client::new(),
                 Box::default()
@@ -868,10 +869,10 @@ mod tests {
             scope: Scopes::new(vec![Scope::Profile, Scope::Create, Scope::Update, Scope::Media]),
             iat: None, exp: None
         };
-        let (uid, mf2) = super::normalize_mf2(post, &user);
+        let NormalizedPost { id, post } = super::normalize_mf2(post, &user);
 
         let err = super::_post(
-            &user, uid, mf2, db.clone(),
+            &user, id, post, db.clone(),
             reqwest_middleware::ClientWithMiddleware::new(
                 reqwest::Client::new(),
                 Box::default()
@@ -903,10 +904,10 @@ mod tests {
             scope: Scopes::new(vec![Scope::Profile, Scope::Create]),
             iat: None, exp: None
         };
-        let (uid, mf2) = super::normalize_mf2(post, &user);
+        let NormalizedPost { id, post } = super::normalize_mf2(post, &user);
 
         let res = super::_post(
-            &user, uid, mf2, db.clone(),
+            &user, id, post, db.clone(),
             reqwest_middleware::ClientWithMiddleware::new(
                 reqwest::Client::new(),
                 Box::default()