pub post_id: Option<PostId>,
pub parent_id: Option<CommentId>,
pub saved_only: Option<bool>,
+ pub liked_only: Option<bool>,
+ pub disliked_only: Option<bool>,
pub auth: Option<Sensitive<String>>,
}
pub community_id: Option<CommunityId>,
pub community_name: Option<String>,
pub saved_only: Option<bool>,
+ pub liked_only: Option<bool>,
+ pub disliked_only: Option<bool>,
pub moderator_view: Option<bool>,
pub auth: Option<Sensitive<String>>,
}
let sort = data.sort;
let max_depth = data.max_depth;
let saved_only = data.saved_only;
+
+ let liked_only = data.liked_only;
+ let disliked_only = data.disliked_only;
+ if liked_only.unwrap_or_default() && disliked_only.unwrap_or_default() {
+ return Err(LemmyError::from(LemmyErrorType::ContradictingFilters));
+ }
+
let page = data.page;
let limit = data.limit;
let parent_id = data.parent_id;
sort,
max_depth,
saved_only,
+ liked_only,
+ disliked_only,
community_id,
parent_path: parent_path_cloned,
post_id,
};
let saved_only = data.saved_only;
+ let liked_only = data.liked_only;
+ let disliked_only = data.disliked_only;
+ if liked_only.unwrap_or_default() && disliked_only.unwrap_or_default() {
+ return Err(LemmyError::from(LemmyErrorType::ContradictingFilters));
+ }
+
let moderator_view = data.moderator_view;
let listing_type = Some(listing_type_with_default(
sort,
community_id,
saved_only,
+ liked_only,
+ disliked_only,
moderator_view,
page,
limit,
query = query.filter(comment_saved::comment_id.is_not_null());
}
+ if options.liked_only.unwrap_or_default() {
+ query = query.filter(comment_like::score.eq(1));
+ } else if options.disliked_only.unwrap_or_default() {
+ query = query.filter(comment_like::score.eq(-1));
+ }
+
let is_creator = options.creator_id == options.local_user.map(|l| l.person.id);
// only show deleted comments to creator
if !is_creator {
pub local_user: Option<&'a LocalUserView>,
pub search_term: Option<String>,
pub saved_only: Option<bool>,
+ pub liked_only: Option<bool>,
+ pub disliked_only: Option<bool>,
pub is_profile_view: bool,
pub page: Option<i64>,
pub limit: Option<i64>,
// Make sure block set the creator blocked
assert!(read_comment_from_blocked_person.creator_blocked);
+ let read_liked_comment_views = CommentQuery {
+ local_user: (Some(&data.local_user_view)),
+ liked_only: (Some(true)),
+ ..Default::default()
+ }
+ .list(pool)
+ .await
+ .unwrap();
+
+ assert_eq!(
+ expected_comment_view_with_person,
+ read_liked_comment_views[0]
+ );
+
+ assert_eq!(1, read_liked_comment_views.len());
+
+ let read_disliked_comment_views: Vec<CommentView> = CommentQuery {
+ local_user: (Some(&data.local_user_view)),
+ disliked_only: (Some(true)),
+ ..Default::default()
+ }
+ .list(pool)
+ .await
+ .unwrap();
+
+ assert!(read_disliked_comment_views.is_empty());
+
cleanup(data, pool).await;
}
}
}
+ if options.liked_only.unwrap_or_default() {
+ query = query.filter(post_like::score.eq(1));
+ } else if options.disliked_only.unwrap_or_default() {
+ query = query.filter(post_like::score.eq(-1));
+ }
+
if options.local_user.is_some() {
// Filter out the rows with missing languages
query = query.filter(local_user_language::language_id.is_not_null());
pub search_term: Option<String>,
pub url_search: Option<String>,
pub saved_only: Option<bool>,
+ pub liked_only: Option<bool>,
+ pub disliked_only: Option<bool>,
pub moderator_view: Option<bool>,
pub is_profile_view: bool,
pub page: Option<i64>,
assert_eq!(expected_post_with_upvote, read_post_listing[0]);
+ let read_liked_post_listing = PostQuery {
+ community_id: (Some(data.inserted_community.id)),
+ local_user: (Some(&data.local_user_view)),
+ liked_only: (Some(true)),
+ ..Default::default()
+ }
+ .list(pool)
+ .await
+ .unwrap();
+ assert_eq!(read_post_listing, read_liked_post_listing);
+
+ let read_disliked_post_listing = PostQuery {
+ community_id: (Some(data.inserted_community.id)),
+ local_user: (Some(&data.local_user_view)),
+ disliked_only: (Some(true)),
+ ..Default::default()
+ }
+ .list(pool)
+ .await
+ .unwrap();
+ assert!(read_disliked_post_listing.is_empty());
+
let like_removed =
PostLike::remove(pool, data.local_user_view.person.id, data.inserted_post.id)
.await
CouldntCreateAudioCaptcha,
InvalidUrlScheme,
CouldntSendWebmention,
+ ContradictingFilters,
Unknown(String),
}