about summary refs log tree commit diff
path: root/kittybox-rs/src/database
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2023-07-22 16:24:26 +0300
committerVika <vika@fireburn.ru>2023-07-22 16:24:26 +0300
commit2443b3592b6df4b717966f165ef5007de2cc22c8 (patch)
tree52f62481a8eb9ab205ec839459ab90c4d0cc48f5 /kittybox-rs/src/database
parent22e5f4894e532203c78c140895851d3c1d6c86df (diff)
downloadkittybox-2443b3592b6df4b717966f165ef5007de2cc22c8.tar.zst
Fix a few bugs
Diffstat (limited to 'kittybox-rs/src/database')
-rw-r--r--kittybox-rs/src/database/file/mod.rs2
-rw-r--r--kittybox-rs/src/database/mod.rs4
-rw-r--r--kittybox-rs/src/database/postgres/mod.rs8
3 files changed, 10 insertions, 4 deletions
diff --git a/kittybox-rs/src/database/file/mod.rs b/kittybox-rs/src/database/file/mod.rs
index ca8e2ac..27d3da1 100644
--- a/kittybox-rs/src/database/file/mod.rs
+++ b/kittybox-rs/src/database/file/mod.rs
@@ -703,7 +703,7 @@ impl Storage for FileStorage {
         };
 
         let key: &'static str = match mention_type {
-            MentionType::Reply => "reply",
+            MentionType::Reply => "comment",
             MentionType::Like => "like",
             MentionType::Repost => "repost",
             MentionType::Bookmark => "bookmark",
diff --git a/kittybox-rs/src/database/mod.rs b/kittybox-rs/src/database/mod.rs
index 98fe6ca..4f1c4de 100644
--- a/kittybox-rs/src/database/mod.rs
+++ b/kittybox-rs/src/database/mod.rs
@@ -708,13 +708,13 @@ mod tests {
         db.add_or_update_webmention(target, TYPE, reply.clone()).await.unwrap();
 
         let (read_post, _) = db.read_feed_with_cursor(target, None, 20, None).await.unwrap().unwrap();
-        assert_eq!(read_post["properties"]["reply"][0], reply);
+        assert_eq!(read_post["properties"]["comment"][0], reply);
 
         reply["properties"]["content"][0] = json!(rand::random::<faker_rand::lorem::Paragraphs>().to_string());
 
         db.add_or_update_webmention(target, TYPE, reply.clone()).await.unwrap();
         let (read_post, _) = db.read_feed_with_cursor(target, None, 20, None).await.unwrap().unwrap();
-        assert_eq!(read_post["properties"]["reply"][0], reply);
+        assert_eq!(read_post["properties"]["comment"][0], reply);
     }
 
     /// Automatically generates a test suite for
diff --git a/kittybox-rs/src/database/postgres/mod.rs b/kittybox-rs/src/database/postgres/mod.rs
index b1a03b1..4477b9c 100644
--- a/kittybox-rs/src/database/postgres/mod.rs
+++ b/kittybox-rs/src/database/postgres/mod.rs
@@ -130,6 +130,7 @@ impl Storage for PostgresStorage {
             .map(|_| ())
     }
 
+    #[tracing::instrument(skip(self))]
     async fn add_or_update_webmention(&self, target: &str, mention_type: MentionType, mention: serde_json::Value) -> Result<()> {
         let mut txn = self.db.begin().await?;
 
@@ -142,13 +143,18 @@ impl Storage for PostgresStorage {
                 "The specified post wasn't found in the database."
             ))?;
 
+        tracing::debug!("Loaded post for target {} with uid {}", target, uid);
+
         let key: &'static str = match mention_type {
-            MentionType::Reply => "reply",
+            MentionType::Reply => "comment",
             MentionType::Like => "like",
             MentionType::Repost => "repost",
             MentionType::Bookmark => "bookmark",
             MentionType::Mention => "mention",
         };
+
+        tracing::debug!("Mention type -> key: {}", key);
+
         let mention_uid = mention["properties"]["uid"][0].clone();
         if let Some(values) = post["properties"][key].as_array_mut() {
             for value in values.iter_mut() {