diff --git a/app/jobs/regular/create_user_reviewable.rb b/app/jobs/regular/create_user_reviewable.rb index 58ed1579b63..27fcaa76c60 100644 --- a/app/jobs/regular/create_user_reviewable.rb +++ b/app/jobs/regular/create_user_reviewable.rb @@ -23,14 +23,15 @@ class Jobs::CreateUserReviewable < Jobs::Base email: user.email } ) - return if @reviewable.score > 0 - @reviewable.add_score( - Discourse.system_user, - ReviewableScore.types[:needs_approval], - reason: reason, - force_review: true - ) + if @reviewable.created_new + @reviewable.add_score( + Discourse.system_user, + ReviewableScore.types[:needs_approval], + reason: reason, + force_review: true + ) + end end end end diff --git a/app/models/reviewable.rb b/app/models/reviewable.rb index 5e9969a00d8..bf468b208ce 100644 --- a/app/models/reviewable.rb +++ b/app/models/reviewable.rb @@ -15,6 +15,7 @@ class Reviewable < ActiveRecord::Base end end + attr_accessor :created_new validates_presence_of :type, :status, :created_by_id belongs_to :target, polymorphic: true belongs_to :created_by, class_name: 'User' @@ -85,7 +86,7 @@ class Reviewable < ActiveRecord::Base topic = target.topic if topic.blank? && target.is_a?(Post) category_id = topic.category_id if topic.present? - create!( + reviewable = create!( target: target, target_created_by_id: target_created_by_id, topic: topic, @@ -95,6 +96,9 @@ class Reviewable < ActiveRecord::Base payload: payload, potential_spam: potential_spam ) + reviewable.created_new = true + reviewable + rescue ActiveRecord::RecordNotUnique row_count = DB.exec(<<~SQL, status: statuses[:pending], id: target.id, type: target.class.name)