Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont allow admin to add mod to remote community #2129

Merged
merged 1 commit into from
Mar 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions crates/api/src/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,13 @@ impl Perform for AddModToCommunity {

// Verify that only mods or admins can add mod
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
let community_moderator_form = CommunityModeratorForm {
Expand Down Expand Up @@ -374,11 +381,7 @@ impl Perform for AddModToCommunity {
})
.await??
.into();
let community: ApubCommunity = blocking(context.pool(), move |conn| {
Community::read(conn, community_id)
})
.await??
.into();
let community: ApubCommunity = community.into();
if data.added {
AddMod::send(
&community,
Expand Down