- let saved_only = data.saved_only;
-
- let listing_type = listing_type_with_default(data.type_, &local_site, community_id)?;
-
- let is_mod_or_admin = is_mod_or_admin_opt(context.pool(), local_user_view.as_ref(), community_id)
- .await
- .is_ok();
-
- let posts = PostQuery::builder()
- .pool(context.pool())
- .local_user(local_user_view.map(|l| l.local_user).as_ref())
- .listing_type(Some(listing_type))
- .sort(sort)
- .community_id(community_id)
- .saved_only(saved_only)
- .page(page)
- .limit(limit)
- .is_mod_or_admin(Some(is_mod_or_admin))
- .build()
- .list()
- .await
- .map_err(|e| LemmyError::from_error_message(e, "couldnt_get_posts"))?;
+ 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 moderator_view = data.moderator_view.unwrap_or_default();
+
+ let listing_type = Some(listing_type_with_default(
+ data.type_,
+ &local_site,
+ community_id,
+ )?);
+
+ let posts = PostQuery {
+ local_user: local_user_view.as_ref(),
+ listing_type,
+ sort,
+ community_id,
+ saved_only,
+ liked_only,
+ disliked_only,
+ moderator_view,
+ page,
+ limit,
+ ..Default::default()
+ }
+ .list(&mut context.pool())
+ .await
+ .with_lemmy_type(LemmyErrorType::CouldntGetPosts)?;