X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fapi_crud%2Fsrc%2Fpost%2Fread.rs;h=af19402ee3e0c82bbb18daeab573237d214f401d;hb=1d38aad9d3d51ef606074d5b49a8030c49dd0e9e;hp=519b748ccd35663bee8b6bbefe803c396fd413aa;hpb=73492af4b09448684ffde3d55454434ec3ed490b;p=lemmy.git diff --git a/crates/api_crud/src/post/read.rs b/crates/api_crud/src/post/read.rs index 519b748c..af19402e 100644 --- a/crates/api_crud/src/post/read.rs +++ b/crates/api_crud/src/post/read.rs @@ -27,7 +27,7 @@ impl PerformCrud for GetPost { async fn perform(&self, context: &Data) -> Result { let data: &GetPost = self; 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(&mut context.pool()).await?; check_private_instance(&local_user_view, &local_site)?; @@ -37,7 +37,7 @@ impl PerformCrud for GetPost { let post_id = if let Some(id) = data.id { id } else if let Some(comment_id) = data.comment_id { - Comment::read(context.pool(), comment_id) + Comment::read(&mut context.pool(), comment_id) .await .with_lemmy_type(LemmyErrorType::CouldntFindPost)? .post_id @@ -46,25 +46,33 @@ impl PerformCrud for GetPost { }; // Check to see if the person is a mod or admin, to show deleted / removed - let community_id = Post::read(context.pool(), post_id).await?.community_id; - let is_mod_or_admin = - is_mod_or_admin_opt(context.pool(), local_user_view.as_ref(), Some(community_id)) - .await - .is_ok(); + let community_id = Post::read(&mut context.pool(), post_id).await?.community_id; + let is_mod_or_admin = is_mod_or_admin_opt( + &mut context.pool(), + local_user_view.as_ref(), + Some(community_id), + ) + .await + .is_ok(); - let post_view = PostView::read(context.pool(), post_id, person_id, Some(is_mod_or_admin)) - .await - .with_lemmy_type(LemmyErrorType::CouldntFindPost)?; + let post_view = PostView::read( + &mut context.pool(), + post_id, + person_id, + Some(is_mod_or_admin), + ) + .await + .with_lemmy_type(LemmyErrorType::CouldntFindPost)?; // Mark the post as read let post_id = post_view.post.id; if let Some(person_id) = person_id { - mark_post_as_read(person_id, post_id, context.pool()).await?; + mark_post_as_read(person_id, post_id, &mut context.pool()).await?; } // Necessary for the sidebar subscribed let community_view = CommunityView::read( - context.pool(), + &mut context.pool(), community_id, person_id, Some(is_mod_or_admin), @@ -82,17 +90,18 @@ impl PerformCrud for GetPost { read_comments, ..PersonPostAggregatesForm::default() }; - PersonPostAggregates::upsert(context.pool(), &person_post_agg_form) + PersonPostAggregates::upsert(&mut context.pool(), &person_post_agg_form) .await .with_lemmy_type(LemmyErrorType::CouldntFindPost)?; } - let moderators = CommunityModeratorView::for_community(context.pool(), community_id).await?; + let moderators = + CommunityModeratorView::for_community(&mut context.pool(), community_id).await?; // Fetch the cross_posts let cross_posts = if let Some(url) = &post_view.post.url { let mut x_posts = PostQuery::builder() - .pool(context.pool()) + .pool(&mut context.pool()) .url_search(Some(url.inner().as_str().into())) .build() .list()