This commit is contained in:
dull b 2023-07-03 18:19:50 +00:00
parent 8f46003ebc
commit 2c47ac35a0
5 changed files with 25 additions and 12 deletions

View file

@ -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)

View file

@ -23,7 +23,7 @@ pub async fn list_comments(
context: Data<LemmyContext>,
) -> Result<Json<GetCommentsResponse>, 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 {

View file

@ -20,7 +20,7 @@ pub async fn list_posts(
context: Data<LemmyContext>,
) -> Result<Json<GetPostsResponse>, 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?)

View file

@ -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"))?;

View file

@ -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 {