about summary refs log tree commit diff
path: root/kittybox-rs/src/micropub
diff options
context:
space:
mode:
Diffstat (limited to 'kittybox-rs/src/micropub')
-rw-r--r--kittybox-rs/src/micropub/mod.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/kittybox-rs/src/micropub/mod.rs b/kittybox-rs/src/micropub/mod.rs
index ee4d334..5c297f9 100644
--- a/kittybox-rs/src/micropub/mod.rs
+++ b/kittybox-rs/src/micropub/mod.rs
@@ -262,9 +262,15 @@ pub(crate) async fn _post<D: 'static + Storage>(
             error_description: "UID clash was detected, operation aborted.".to_owned(),
         });
     }
-
+    let user_domain = format!(
+        "{}{}",
+        user.me.host_str().unwrap(),
+        user.me.port()
+            .map(|port| format!(":{}", port))
+            .unwrap_or_default()
+    );
     // Save the post
-    db.put_post(&mf2, user.me.as_str()).await?;
+    db.put_post(&mf2, &user_domain).await?;
 
     let mut channels = mf2["properties"]["channel"]
         .as_array()
@@ -521,7 +527,13 @@ pub(crate) async fn query<D: Storage, A: AuthBackend>(
             .into_response();
     }
 
-    
+    let user_domain = format!(
+        "{}{}",
+        user.me.host_str().unwrap(),
+        user.me.port()
+            .map(|port| format!(":{}", port))
+            .unwrap_or_default()
+    );
     match query.q {
         QueryType::Config => {
             let channels: Vec<MicropubChannel> = match db.get_channels(user.me.as_str()).await {
@@ -580,7 +592,7 @@ pub(crate) async fn query<D: Storage, A: AuthBackend>(
                 }
             }
         }
-        QueryType::Channel => match db.get_channels(user.me.as_str()).await {
+        QueryType::Channel => match db.get_channels(&user_domain).await {
             Ok(chans) => axum::response::Json(json!({ "channels": chans })).into_response(),
             Err(err) => MicropubError::new(
                 ErrorType::InternalServerError,