about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/micropub/mod.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/micropub/mod.rs b/src/micropub/mod.rs
index 4a501bb..835457f 100644
--- a/src/micropub/mod.rs
+++ b/src/micropub/mod.rs
@@ -26,6 +26,7 @@ enum QueryType {
     Config,
     Channel,
     SyndicateTo,
+    Category
 }
 
 #[derive(Serialize, Deserialize, Debug)]
@@ -593,7 +594,8 @@ pub(crate) async fn query<D: Storage, A: AuthBackend>(
                     QueryType::Source,
                     QueryType::Config,
                     QueryType::Channel,
-                    QueryType::SyndicateTo
+                    QueryType::SyndicateTo,
+                    QueryType::Category
                 ],
                 "channels": channels,
                 "_kittybox_authority": user.me.as_str(),
@@ -643,6 +645,18 @@ pub(crate) async fn query<D: Storage, A: AuthBackend>(
         },
         QueryType::SyndicateTo => {
             axum::response::Json(json!({ "syndicate-to": [] })).into_response()
+        },
+        QueryType::Category => {
+            let categories = match db.categories(&user_domain).await {
+                Ok(categories) => categories,
+                Err(err) => {
+                    return MicropubError::new(
+                        ErrorType::InternalServerError,
+                        &format!("Error fetching categories: {}", err)
+                    ).into_response()
+                }
+            };
+            axum::response::Json(json!({ "categories": categories })).into_response()
         }
     }
 }