mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 08:42:44 +08:00
FIX: Don't create two reviewable scores for a user
This commit is contained in:
parent
c1ea63bdc1
commit
82bddcbe51
|
@ -5,7 +5,7 @@ class Jobs::CreateUserReviewable < Jobs::Base
|
||||||
if user = User.find_by(id: args[:user_id])
|
if user = User.find_by(id: args[:user_id])
|
||||||
return if user.approved?
|
return if user.approved?
|
||||||
|
|
||||||
reviewable = ReviewableUser.needs_review!(target: user, created_by: Discourse.system_user, reviewable_by_moderator: true)
|
reviewable = ReviewableUser.create!(target: user, created_by: Discourse.system_user, reviewable_by_moderator: true)
|
||||||
reviewable.add_score(
|
reviewable.add_score(
|
||||||
Discourse.system_user,
|
Discourse.system_user,
|
||||||
ReviewableScore.types[:needs_approval],
|
ReviewableScore.types[:needs_approval],
|
||||||
|
|
|
@ -57,7 +57,7 @@ class EmailToken < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.confirm(token)
|
def self.confirm(token, skip_reviewable: false)
|
||||||
User.transaction do
|
User.transaction do
|
||||||
result = atomic_confirm(token)
|
result = atomic_confirm(token)
|
||||||
user = result[:user]
|
user = result[:user]
|
||||||
|
@ -65,8 +65,9 @@ class EmailToken < ActiveRecord::Base
|
||||||
# If we are activating the user, send the welcome message
|
# If we are activating the user, send the welcome message
|
||||||
user.send_welcome_message = !user.active?
|
user.send_welcome_message = !user.active?
|
||||||
user.email = result[:email_token].email
|
user.email = result[:email_token].email
|
||||||
|
user.active = true
|
||||||
user.save!
|
user.save!
|
||||||
user.activate
|
user.create_reviewable unless skip_reviewable
|
||||||
user.set_automatic_groups
|
user.set_automatic_groups
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -892,7 +892,7 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
def activate
|
def activate
|
||||||
if email_token = self.email_tokens.active.where(email: self.email).first
|
if email_token = self.email_tokens.active.where(email: self.email).first
|
||||||
user = EmailToken.confirm(email_token.token)
|
user = EmailToken.confirm(email_token.token, skip_reviewable: true)
|
||||||
self.update!(active: true) if user.nil?
|
self.update!(active: true) if user.nil?
|
||||||
else
|
else
|
||||||
self.update!(active: true)
|
self.update!(active: true)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user