mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:21:18 +08:00
FIX: Better handling for toggling must_approve_users
If you turn it on now, default all users to approved since they were previously. Also support approving a user that doesn't have a reviewable record (it will be created first.) This also includes a refactor to move class method calls to `DiscourseEvent` into an initializer. Otherwise the load order of classes makes a difference in the test environment and some settings might be triggered and others not, randomly.
This commit is contained in:
@ -288,7 +288,12 @@ class Admin::UsersController < Admin::AdminController
|
||||
end
|
||||
|
||||
def approve
|
||||
Reviewable.bulk_perform_targets(current_user, :approve, 'ReviewableUser', [@user.id])
|
||||
guardian.ensure_can_approve!(@user)
|
||||
|
||||
reviewable = ReviewableUser.find_by(target: @user) ||
|
||||
Jobs::CreateUserReviewable.new.execute(user_id: @user.id).reviewable
|
||||
|
||||
reviewable.perform(current_user, :approve)
|
||||
render body: nil
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user