mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 06:36:14 +00:00
parent
8e3ff0408e
commit
cf426493e1
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2588,7 +2588,7 @@ dependencies = [
|
||||||
"actix-web",
|
"actix-web",
|
||||||
"actix-web-httpauth",
|
"actix-web-httpauth",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64 0.21.7",
|
"base64 0.22.0",
|
||||||
"bcrypt",
|
"bcrypt",
|
||||||
"captcha",
|
"captcha",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|
|
@ -36,9 +36,21 @@ pub async fn add_mod_to_community(
|
||||||
let community = Community::read(&mut context.pool(), community_id)
|
let community = Community::read(&mut context.pool(), community_id)
|
||||||
.await?
|
.await?
|
||||||
.ok_or(LemmyErrorType::CouldntFindCommunity)?;
|
.ok_or(LemmyErrorType::CouldntFindCommunity)?;
|
||||||
|
|
||||||
|
// If user is admin and community is remote, explicitly check that he is a
|
||||||
|
// moderator. This is necessary because otherwise the action would be rejected
|
||||||
|
// by the community's home instance.
|
||||||
if local_user_view.local_user.admin && !community.local {
|
if local_user_view.local_user.admin && !community.local {
|
||||||
|
let is_mod = CommunityModeratorView::is_community_moderator(
|
||||||
|
&mut context.pool(),
|
||||||
|
community.id,
|
||||||
|
local_user_view.person.id,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
if !is_mod {
|
||||||
Err(LemmyErrorType::NotAModerator)?
|
Err(LemmyErrorType::NotAModerator)?
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update in local database
|
// Update in local database
|
||||||
let community_moderator_form = CommunityModeratorForm {
|
let community_moderator_form = CommunityModeratorForm {
|
||||||
|
|
Loading…
Reference in a new issue