+ .load::<CommunityViewTuple>(&mut conn)
+ .await
+ };
+
+ Queries::new(read, list)
+}
+
+impl CommunityView {
+ pub async fn read(
+ pool: &mut DbPool<'_>,
+ community_id: CommunityId,
+ my_person_id: Option<PersonId>,
+ is_mod_or_admin: bool,
+ ) -> Result<Self, Error> {
+ queries()
+ .read(pool, (community_id, my_person_id, is_mod_or_admin))
+ .await
+ }
+
+ 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
+ }
+}