- let (
- post,
- creator,
- community,
- creator_banned_from_community,
- counts,
- follower,
- saved,
- read,
- creator_blocked,
- post_like,
- unread_comments,
- ) = query.first::<PostViewTuple>(conn).await?;
-
- // If a person is given, then my_vote, if None, should be 0, not null
- // Necessary to differentiate between other person's votes
- let my_vote = if my_person_id.is_some() && post_like.is_none() {
- Some(0)
- } else {
- post_like
- };
-
- Ok(PostView {
- post,
- creator,
- community,
- creator_banned_from_community: creator_banned_from_community.is_some(),
- counts,
- subscribed: CommunityFollower::to_subscribed_type(&follower),
- saved: saved.is_some(),
- read: read.is_some(),
- creator_blocked: creator_blocked.is_some(),
- my_vote,
- unread_comments,
- })
- }
-}
-
-#[derive(TypedBuilder)]
-#[builder(field_defaults(default))]
-pub struct PostQuery<'a> {
- #[builder(!default)]
- pool: &'a DbPool,
- listing_type: Option<ListingType>,
- sort: Option<SortType>,
- creator_id: Option<PersonId>,
- community_id: Option<CommunityId>,
- local_user: Option<&'a LocalUser>,
- search_term: Option<String>,
- url_search: Option<String>,
- saved_only: Option<bool>,
- /// Used to show deleted or removed posts for admins
- is_mod_or_admin: Option<bool>,
- page: Option<i64>,
- limit: Option<i64>,
-}