- 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(Default)]
-pub struct PostQuery<'a> {
- pub listing_type: Option<ListingType>,
- pub sort: Option<SortType>,
- pub creator_id: Option<PersonId>,
- pub community_id: Option<CommunityId>,
- pub local_user: Option<&'a LocalUserView>,
- pub search_term: Option<String>,
- pub url_search: Option<String>,
- pub saved_only: Option<bool>,
- pub is_profile_view: Option<bool>,
- pub page: Option<i64>,
- pub limit: Option<i64>,
-}