]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/api/list_comments.rs
Replace Option<bool> with bool for PostQuery and CommentQuery (#3819) (#3857)
[lemmy.git] / crates / apub / src / api / list_comments.rs
index b64871221d67b57c15774f5f053b760d41500b78..5d7aa387bbab8b0fb1741b0a79ea26f39719ee37 100644 (file)
@@ -34,7 +34,14 @@ pub async fn list_comments(
   };
   let sort = data.sort;
   let max_depth = data.max_depth;
-  let saved_only = data.saved_only;
+  let saved_only = data.saved_only.unwrap_or_default();
+
+  let liked_only = data.liked_only.unwrap_or_default();
+  let disliked_only = data.disliked_only.unwrap_or_default();
+  if liked_only && disliked_only {
+    return Err(LemmyError::from(LemmyErrorType::ContradictingFilters));
+  }
+
   let page = data.page;
   let limit = data.limit;
   let parent_id = data.parent_id;
@@ -54,16 +61,17 @@ pub async fn list_comments(
 
   let parent_path_cloned = parent_path.clone();
   let post_id = data.post_id;
-  let local_user = local_user_view.map(|l| l.local_user);
   let comments = CommentQuery {
     listing_type,
     sort,
     max_depth,
     saved_only,
+    liked_only,
+    disliked_only,
     community_id,
     parent_path: parent_path_cloned,
     post_id,
-    local_user: local_user.as_ref(),
+    local_user: local_user_view.as_ref(),
     page,
     limit,
     ..Default::default()