- let (community, counts, follower, blocked) = query.first::<CommunityViewTuple>(conn).await?;
-
- Ok(CommunityView {
- community,
- subscribed: CommunityFollower::to_subscribed_type(&follower),
- blocked: blocked.is_some(),
- counts,
- })
- }
-
- pub async fn is_mod_or_admin(
- pool: &mut DbPool<'_>,
- person_id: PersonId,
- community_id: CommunityId,
- ) -> Result<bool, Error> {
- let is_mod =
- CommunityModeratorView::is_community_moderator(pool, community_id, person_id).await?;
- if is_mod {
- return Ok(true);
- }
-
- PersonView::is_admin(pool, person_id).await
- }
-}
-
-#[derive(Default)]
-pub struct CommunityQuery<'a> {
- pub listing_type: Option<ListingType>,
- pub sort: Option<SortType>,
- pub local_user: Option<&'a LocalUser>,
- pub search_term: Option<String>,
- pub is_mod_or_admin: Option<bool>,
- pub show_nsfw: Option<bool>,
- pub page: Option<i64>,
- pub limit: Option<i64>,
-}