mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-23 12:51:18 +00:00
parent
c6c0fb047d
commit
8378810e0e
2 changed files with 13 additions and 9 deletions
|
@ -605,8 +605,15 @@ impl Perform<GetCommunityResponse> for Oper<TransferCommunity> {
|
|||
|
||||
let read_community = Community::read(&conn, data.community_id)?;
|
||||
|
||||
// Make sure user is the creator
|
||||
if read_community.creator_id != user_id {
|
||||
let site_creator_id = Site::read(&conn, 1)?.creator_id;
|
||||
let mut admins = UserView::admins(&conn)?;
|
||||
let creator_index = admins.iter().position(|r| r.id == site_creator_id).unwrap();
|
||||
let creator_user = admins.remove(creator_index);
|
||||
admins.insert(0, creator_user);
|
||||
|
||||
|
||||
// Make sure user is the creator, or an admin
|
||||
if user_id != read_community.creator_id && !admins.iter().map(|a| a.id).collect::<Vec<i32>>().contains(&user_id) {
|
||||
return Err(APIError::err(&self.op, "not_an_admin"))?
|
||||
}
|
||||
|
||||
|
@ -675,11 +682,6 @@ impl Perform<GetCommunityResponse> for Oper<TransferCommunity> {
|
|||
}
|
||||
};
|
||||
|
||||
let site_creator_id = Site::read(&conn, 1)?.creator_id;
|
||||
let mut admins = UserView::admins(&conn)?;
|
||||
let creator_index = admins.iter().position(|r| r.id == site_creator_id).unwrap();
|
||||
let creator_user = admins.remove(creator_index);
|
||||
admins.insert(0, creator_user);
|
||||
|
||||
// Return the jwt
|
||||
Ok(
|
||||
|
|
6
ui/src/components/comment-node.tsx
vendored
6
ui/src/components/comment-node.tsx
vendored
|
@ -152,8 +152,8 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
|||
}
|
||||
</>
|
||||
}
|
||||
{/* Community creators can transfer community to another mod */}
|
||||
{this.amCommunityCreator && this.isMod &&
|
||||
{/* Community creators and admins can transfer community to another mod */}
|
||||
{(this.amCommunityCreator || this.canAdmin) && this.isMod &&
|
||||
<li className="list-inline-item">
|
||||
{!this.state.showConfirmTransferCommunity ?
|
||||
<span class="pointer" onClick={linkEvent(this, this.handleShowConfirmTransferCommunity)}><T i18nKey="transfer_community">#</T>
|
||||
|
@ -491,6 +491,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
|||
user_id: i.props.node.comment.creator_id,
|
||||
};
|
||||
WebSocketService.Instance.transferCommunity(form);
|
||||
i.state.showConfirmTransferCommunity = false;
|
||||
i.setState(i.state);
|
||||
}
|
||||
|
||||
|
@ -509,6 +510,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
|||
user_id: i.props.node.comment.creator_id,
|
||||
};
|
||||
WebSocketService.Instance.transferSite(form);
|
||||
i.state.showConfirmTransferSite = false;
|
||||
i.setState(i.state);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue