about summary refs log tree commit diff
path: root/src/micropub
diff options
context:
space:
mode:
Diffstat (limited to 'src/micropub')
-rw-r--r--src/micropub/mod.rs35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/micropub/mod.rs b/src/micropub/mod.rs
index 08150d2..8f95085 100644
--- a/src/micropub/mod.rs
+++ b/src/micropub/mod.rs
@@ -82,7 +82,7 @@ fn populate_reply_context(
 async fn background_processing<D: 'static + Storage>(
     db: D,
     mf2: serde_json::Value,
-    http: reqwest::Client,
+    http: reqwest_middleware::ClientWithMiddleware,
 ) -> () {
     // TODO: Post-processing the post (aka second write pass)
     // - [x] Download rich reply contexts
@@ -232,7 +232,7 @@ pub(crate) async fn _post<D: 'static + Storage>(
     uid: String,
     mf2: serde_json::Value,
     db: D,
-    http: reqwest::Client,
+    http: reqwest_middleware::ClientWithMiddleware,
     jobset: Arc<Mutex<JoinSet<()>>>,
 ) -> Result<Response, MicropubError> {
     // Here, we have the following guarantees:
@@ -501,7 +501,7 @@ async fn dispatch_body(
 #[tracing::instrument(skip(db, http))]
 pub(crate) async fn post<D: Storage + 'static, A: AuthBackend>(
     State(db): State<D>,
-    State(http): State<reqwest::Client>,
+    State(http): State<reqwest_middleware::ClientWithMiddleware>,
     State(jobset): State<Arc<Mutex<JoinSet<()>>>>,
     TypedHeader(content_type): TypedHeader<ContentType>,
     user: User<A>,
@@ -655,7 +655,7 @@ pub fn router<A, S, St: Send + Sync + Clone + 'static>() -> axum::routing::Metho
 where
     S: Storage + FromRef<St> + 'static,
     A: AuthBackend + FromRef<St>,
-    reqwest::Client: FromRef<St>,
+    reqwest_middleware::ClientWithMiddleware: FromRef<St>,
     Arc<Mutex<JoinSet<()>>>: FromRef<St>
 {
     axum::routing::get(query::<S, A>)
@@ -758,7 +758,14 @@ mod tests {
         };
         let (uid, mf2) = super::normalize_mf2(post, &user);
 
-        let err = super::_post(&user, uid, mf2, db.clone(), reqwest::Client::new(), Arc::new(Mutex::new(tokio::task::JoinSet::new())))
+        let err = super::_post(
+            &user, uid, mf2, db.clone(),
+            reqwest_middleware::ClientWithMiddleware::new(
+                reqwest::Client::new(),
+                Box::default()
+            ),
+            Arc::new(Mutex::new(tokio::task::JoinSet::new()))
+        )
             .await
             .unwrap_err();
 
@@ -788,7 +795,14 @@ mod tests {
         };
         let (uid, mf2) = super::normalize_mf2(post, &user);
 
-        let err = super::_post(&user, uid, mf2, db.clone(), reqwest::Client::new(), Arc::new(Mutex::new(tokio::task::JoinSet::new())))
+        let err = super::_post(
+            &user, uid, mf2, db.clone(),
+            reqwest_middleware::ClientWithMiddleware::new(
+                reqwest::Client::new(),
+                Box::default()
+            ),
+            Arc::new(Mutex::new(tokio::task::JoinSet::new()))
+        )
             .await
             .unwrap_err();
 
@@ -816,7 +830,14 @@ mod tests {
         };
         let (uid, mf2) = super::normalize_mf2(post, &user);
 
-        let res = super::_post(&user, uid, mf2, db.clone(), reqwest::Client::new(), Arc::new(Mutex::new(tokio::task::JoinSet::new())))
+        let res = super::_post(
+            &user, uid, mf2, db.clone(),
+            reqwest_middleware::ClientWithMiddleware::new(
+                reqwest::Client::new(),
+                Box::default()
+            ),
+            Arc::new(Mutex::new(tokio::task::JoinSet::new()))
+        )
             .await
             .unwrap();