Dont allow admin to add mod to remote community (#2129)

revert-2099
Nutomic 2022-03-14 18:35:57 +00:00 committed by GitHub
parent f8fb3b41f0
commit 550a93aed9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -335,6 +335,13 @@ impl Perform for AddModToCommunity {
// Verify that only mods or admins can add mod // Verify that only mods or admins can add mod
is_mod_or_admin(context.pool(), local_user_view.person.id, community_id).await?; is_mod_or_admin(context.pool(), local_user_view.person.id, community_id).await?;
let community = blocking(context.pool(), move |conn| {
Community::read(conn, community_id)
})
.await??;
if local_user_view.person.admin && !community.local {
return Err(LemmyError::from_message("not_a_moderator"));
}
// Update in local database // Update in local database
let community_moderator_form = CommunityModeratorForm { let community_moderator_form = CommunityModeratorForm {
@ -374,11 +381,7 @@ impl Perform for AddModToCommunity {
}) })
.await?? .await??
.into(); .into();
let community: ApubCommunity = blocking(context.pool(), move |conn| { let community: ApubCommunity = community.into();
Community::read(conn, community_id)
})
.await??
.into();
if data.added { if data.added {
AddMod::send( AddMod::send(
&community, &community,