From 2c47ac35a0d8a5a16c414a02af73d3fb608ca76a Mon Sep 17 00:00:00 2001 From: dull b Date: Mon, 3 Jul 2023 18:19:50 +0000 Subject: [PATCH] fix --- crates/api/src/community/follow.rs | 7 ++++++- crates/apub/src/api/list_comments.rs | 2 +- crates/apub/src/api/list_posts.rs | 12 ++++++++---- crates/apub/src/api/read_community.rs | 13 ++++++++----- crates/apub/src/api/read_person.rs | 3 ++- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/crates/api/src/community/follow.rs b/crates/api/src/community/follow.rs index 96cfd0b99..30958299d 100644 --- a/crates/api/src/community/follow.rs +++ b/crates/api/src/community/follow.rs @@ -34,7 +34,12 @@ impl Perform for FollowCommunity { if data.follow { if community.local { - check_community_ban(local_user_view.person.id, community_id, context.conn().await?).await?; + check_community_ban( + local_user_view.person.id, + community_id, + context.conn().await?, + ) + .await?; check_community_deleted_or_removed(community_id, context.conn().await?).await?; CommunityFollower::follow(context.conn().await?, &community_follower_form) diff --git a/crates/apub/src/api/list_comments.rs b/crates/apub/src/api/list_comments.rs index 1188d68e2..292f22188 100644 --- a/crates/apub/src/api/list_comments.rs +++ b/crates/apub/src/api/list_comments.rs @@ -23,7 +23,7 @@ pub async fn list_comments( context: Data, ) -> Result, LemmyError> { let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), &context).await; - let local_site = LocalSite::read(context.pool()).await?; + let local_site = LocalSite::read(context.conn().await?).await?; check_private_instance(&local_user_view, &local_site)?; let community_id = if let Some(name) = &data.community_name { diff --git a/crates/apub/src/api/list_posts.rs b/crates/apub/src/api/list_posts.rs index 1ea4efb2f..b041ce9b6 100644 --- a/crates/apub/src/api/list_posts.rs +++ b/crates/apub/src/api/list_posts.rs @@ -20,7 +20,7 @@ pub async fn list_posts( context: Data, ) -> Result, LemmyError> { let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), &context).await; - let local_site = LocalSite::read(context.pool()).await?; + let local_site = LocalSite::read(context.conn().await?).await?; check_private_instance(&local_user_view, &local_site)?; @@ -40,9 +40,13 @@ pub async fn list_posts( let listing_type = listing_type_with_default(data.type_, &local_site, community_id)?; - let is_mod_or_admin = is_mod_or_admin_opt(context.pool(), local_user_view.as_ref(), community_id) - .await - .is_ok(); + let is_mod_or_admin = is_mod_or_admin_opt( + context.conn().await?, + local_user_view.as_ref(), + community_id, + ) + .await + .is_ok(); let posts = PostQuery::builder() .conn(context.conn().await?) diff --git a/crates/apub/src/api/read_community.rs b/crates/apub/src/api/read_community.rs index ae373031b..922c35651 100644 --- a/crates/apub/src/api/read_community.rs +++ b/crates/apub/src/api/read_community.rs @@ -42,10 +42,13 @@ pub async fn read_community( } }; - let is_mod_or_admin = - is_mod_or_admin_opt(context.conn().await?, local_user_view.as_ref(), Some(community_id)) - .await - .is_ok(); + let is_mod_or_admin = is_mod_or_admin_opt( + context.conn().await?, + local_user_view.as_ref(), + Some(community_id), + ) + .await + .is_ok(); let community_view = CommunityView::read( context.conn().await?, @@ -56,7 +59,7 @@ pub async fn read_community( .await .map_err(|e| LemmyError::from_error_message(e, "couldnt_find_community"))?; - let moderators = CommunityModeratorView::for_community(context.pool(), community_id) + let moderators = CommunityModeratorView::for_community(context.conn().await?, community_id) .await .map_err(|e| LemmyError::from_error_message(e, "couldnt_find_community"))?; diff --git a/crates/apub/src/api/read_person.rs b/crates/apub/src/api/read_person.rs index dddc821ae..be16b5773 100644 --- a/crates/apub/src/api/read_person.rs +++ b/crates/apub/src/api/read_person.rs @@ -102,7 +102,8 @@ pub async fn read_person( } .await?; - let moderates = CommunityModeratorView::for_person(context.conn().await?, person_details_id).await?; + let moderates = + CommunityModeratorView::for_person(context.conn().await?, person_details_id).await?; // Return the jwt Ok(Json(GetPersonDetailsResponse {