mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 22:31:20 +00:00
fix
This commit is contained in:
parent
8f46003ebc
commit
2c47ac35a0
5 changed files with 25 additions and 12 deletions
|
@ -34,7 +34,12 @@ impl Perform for FollowCommunity {
|
||||||
|
|
||||||
if data.follow {
|
if data.follow {
|
||||||
if community.local {
|
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?;
|
check_community_deleted_or_removed(community_id, context.conn().await?).await?;
|
||||||
|
|
||||||
CommunityFollower::follow(context.conn().await?, &community_follower_form)
|
CommunityFollower::follow(context.conn().await?, &community_follower_form)
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub async fn list_comments(
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
) -> Result<Json<GetCommentsResponse>, LemmyError> {
|
) -> Result<Json<GetCommentsResponse>, LemmyError> {
|
||||||
let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), &context).await;
|
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)?;
|
check_private_instance(&local_user_view, &local_site)?;
|
||||||
|
|
||||||
let community_id = if let Some(name) = &data.community_name {
|
let community_id = if let Some(name) = &data.community_name {
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub async fn list_posts(
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
) -> Result<Json<GetPostsResponse>, LemmyError> {
|
) -> Result<Json<GetPostsResponse>, LemmyError> {
|
||||||
let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), &context).await;
|
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)?;
|
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 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)
|
let is_mod_or_admin = is_mod_or_admin_opt(
|
||||||
.await
|
context.conn().await?,
|
||||||
.is_ok();
|
local_user_view.as_ref(),
|
||||||
|
community_id,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.is_ok();
|
||||||
|
|
||||||
let posts = PostQuery::builder()
|
let posts = PostQuery::builder()
|
||||||
.conn(context.conn().await?)
|
.conn(context.conn().await?)
|
||||||
|
|
|
@ -42,10 +42,13 @@ pub async fn read_community(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let is_mod_or_admin =
|
let is_mod_or_admin = is_mod_or_admin_opt(
|
||||||
is_mod_or_admin_opt(context.conn().await?, local_user_view.as_ref(), Some(community_id))
|
context.conn().await?,
|
||||||
.await
|
local_user_view.as_ref(),
|
||||||
.is_ok();
|
Some(community_id),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.is_ok();
|
||||||
|
|
||||||
let community_view = CommunityView::read(
|
let community_view = CommunityView::read(
|
||||||
context.conn().await?,
|
context.conn().await?,
|
||||||
|
@ -56,7 +59,7 @@ pub async fn read_community(
|
||||||
.await
|
.await
|
||||||
.map_err(|e| LemmyError::from_error_message(e, "couldnt_find_community"))?;
|
.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
|
.await
|
||||||
.map_err(|e| LemmyError::from_error_message(e, "couldnt_find_community"))?;
|
.map_err(|e| LemmyError::from_error_message(e, "couldnt_find_community"))?;
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,8 @@ pub async fn read_person(
|
||||||
}
|
}
|
||||||
.await?;
|
.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
|
// Return the jwt
|
||||||
Ok(Json(GetPersonDetailsResponse {
|
Ok(Json(GetPersonDetailsResponse {
|
||||||
|
|
Loading…
Reference in a new issue