mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Don't log a second pending action
If two people flagged the same post you'd get a "Pending" history event logged which looked bad.
This commit is contained in:
@@ -93,12 +93,20 @@ class Reviewable < ActiveRecord::Base
|
||||
potential_spam: potential_spam
|
||||
)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
updates = {
|
||||
status: statuses[:pending]
|
||||
}
|
||||
updates[:potential_spam] = true if potential_spam
|
||||
where(target: target).update_all(updates)
|
||||
find_by(target: target).tap { |r| r.log_history(:transitioned, created_by) }
|
||||
|
||||
row_count = DB.exec(<<~SQL, status: statuses[:pending], id: target.id, type: target.class.name)
|
||||
UPDATE reviewables
|
||||
SET status = :status
|
||||
WHERE status <> :status
|
||||
AND target_id = :id
|
||||
AND target_type = :type
|
||||
SQL
|
||||
|
||||
where(target: target).update_all(potential_spam: true) if potential_spam
|
||||
|
||||
reviewable = find_by(target: target)
|
||||
reviewable.log_history(:transitioned, created_by) if row_count > 0
|
||||
reviewable
|
||||
end
|
||||
|
||||
def add_score(
|
||||
@@ -219,6 +227,7 @@ class Reviewable < ActiveRecord::Base
|
||||
|
||||
self.status = Reviewable.statuses[status_symbol]
|
||||
save!
|
||||
|
||||
log_history(:transitioned, performed_by)
|
||||
DiscourseEvent.trigger(:reviewable_transitioned_to, status_symbol, self)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user