- 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(TypedBuilder)]
-#[builder(field_defaults(default))]
-pub struct CommunityQuery<'a, 'b: 'a> {
- #[builder(!default)]
- pool: &'a mut DbPool<'b>,
- listing_type: Option<ListingType>,
- sort: Option<SortType>,
- local_user: Option<&'a LocalUser>,
- search_term: Option<String>,
- is_mod_or_admin: Option<bool>,
- show_nsfw: Option<bool>,
- page: Option<i64>,
- limit: Option<i64>,
-}
-
-impl<'a, 'b: 'a> CommunityQuery<'a, 'b> {
- pub async fn list(self) -> Result<Vec<CommunityView>, Error> {