about summary refs log tree commit diff
path: root/kittybox-rs/src/database/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'kittybox-rs/src/database/mod.rs')
-rw-r--r--kittybox-rs/src/database/mod.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/kittybox-rs/src/database/mod.rs b/kittybox-rs/src/database/mod.rs
index 94a93ca..baae81d 100644
--- a/kittybox-rs/src/database/mod.rs
+++ b/kittybox-rs/src/database/mod.rs
@@ -5,6 +5,7 @@ use async_trait::async_trait;
 
 mod file;
 pub use crate::database::file::FileStorage;
+use crate::micropub::MicropubUpdate;
 #[cfg(test)]
 mod memory;
 #[cfg(test)]
@@ -295,10 +296,10 @@ pub trait Storage: std::fmt::Debug + Clone + Send + Sync {
 
     /// Add post to feed. Some database implementations might have optimized ways to do this.
     async fn add_to_feed(&self, feed: &'_ str, post: &'_ str) -> Result<()> {
-        self.update_post(feed, serde_json::json!({"add": {"children": [post]}})).await
+        self.update_post(feed, serde_json::from_str(r#"{"add": {"children": [post]}}"#).unwrap()).await
     }
     async fn remove_from_feed(&self, feed: &'_ str, post: &'_ str) -> Result<()> {
-        self.update_post(feed, serde_json::json!({"delete": {"children": [post]}})).await
+        self.update_post(feed, serde_json::from_str(r#"{"delete": {"children": [post]}}"#).unwrap()).await
     }
 
     /// Modify a post using an update object as defined in the Micropub spec.
@@ -308,7 +309,7 @@ pub trait Storage: std::fmt::Debug + Clone + Send + Sync {
     /// each other's changes or simply corrupting something. Rejecting
     /// is allowed in case of concurrent updates if waiting for a lock
     /// cannot be done.
-    async fn update_post(&self, url: &'_ str, update: serde_json::Value) -> Result<()>;
+    async fn update_post(&self, url: &str, update: MicropubUpdate) -> Result<()>;
 
     /// Get a list of channels available for the user represented by the URL `user` to write to.
     async fn get_channels(&self, user: &'_ str) -> Result<Vec<MicropubChannel>>;
@@ -449,7 +450,7 @@ mod tests {
         backend
             .update_post(
                 &key,
-                json!({
+                serde_json::from_value(json!({
                     "url": &key,
                     "add": {
                         "category": ["testing"],
@@ -457,7 +458,7 @@ mod tests {
                     "replace": {
                         "content": ["Different test content"]
                     }
-                }),
+                })).unwrap(),
             )
             .await
             .unwrap();