discourse/app/jobs/regular/create_user_reviewable.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1.0 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
class Jobs::CreateUserReviewable < ::Jobs::Base
attr_reader :reviewable
def execute(args)
raise Discourse::InvalidParameters unless args[:user_id].present?
reason = nil
reason ||= :must_approve_users if SiteSetting.must_approve_users?
reason ||= :invite_only if SiteSetting.invite_only?
return unless reason
if user = User.find_by(id: args[:user_id])
return if user.approved?
@reviewable =
ReviewableUser.needs_review!(
target: user,
created_by: Discourse.system_user,
reviewable_by_moderator: true,
payload: {
username: user.username,
name: user.name,
2020-02-19 10:18:05 -05:00
email: user.email,
website: user.user_profile&.website,
},
)
2019-04-23 15:53:37 -04:00
if @reviewable.created_new
@reviewable.add_score(
Discourse.system_user,
ReviewableScore.types[:needs_approval],
reason: reason,
force_review: true,
)
end
end
end
end