X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fapub%2Fsrc%2Fapi%2Flist_posts.rs;h=c60abc966017b5bb6ade4fc39fe322d7e0c78c82;hb=88215bfbc98b70595035426c06cfe67f4a9ab0ab;hp=929cb95c30006b3dc04f3731d1b12b3a653360cc;hpb=93225e5ddfd48e613afe51984243112a1bedfcc2;p=lemmy.git diff --git a/crates/apub/src/api/list_posts.rs b/crates/apub/src/api/list_posts.rs index 929cb95c..c60abc96 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(&mut context.pool()).await?; check_private_instance(&local_user_view, &local_site)?; @@ -36,26 +36,32 @@ pub async fn list_posts( }; let saved_only = data.saved_only; - 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 posts = PostQuery::builder() - .pool(context.pool()) - .local_user(local_user_view.map(|l| l.local_user).as_ref()) - .listing_type(Some(listing_type)) - .sort(sort) - .community_id(community_id) - .saved_only(saved_only) - .page(page) - .limit(limit) - .is_mod_or_admin(Some(is_mod_or_admin)) - .build() - .list() - .await - .with_lemmy_type(LemmyErrorType::CouldntGetPosts)?; + let listing_type = Some(listing_type_with_default( + data.type_, + &local_site, + community_id, + )?); + + let is_mod_or_admin = Some( + is_mod_or_admin_opt(&mut context.pool(), local_user_view.as_ref(), community_id) + .await + .is_ok(), + ); + + let posts = PostQuery { + local_user: local_user_view.map(|l| l.local_user).as_ref(), + listing_type, + sort, + community_id, + saved_only, + page, + limit, + is_mod_or_admin, + ..Default::default() + } + .list(&mut context.pool()) + .await + .with_lemmy_type(LemmyErrorType::CouldntGetPosts)?; Ok(Json(GetPostsResponse { posts })) }