FIX: Notify on Reviewable update. (#7980)

If a post is flagged after an action was already performed on it, it
will update the previous Reviable instance and not create a new one.
The notification logic was implemented in the :create callback which was
completely skipped in this case.
This commit is contained in:
Dan Ungureanu
2019-08-08 16:04:34 +02:00
committed by Régis Hanol
parent 6d3d08daad
commit 3008ecccbd
2 changed files with 16 additions and 0 deletions
+3
View File
@@ -38,6 +38,9 @@ class Reviewable < ActiveRecord::Base
after_commit(on: :create) do
DiscourseEvent.trigger(:reviewable_created, self)
end
after_commit(on: [:create, :update]) do
Jobs.enqueue(:notify_reviewable, reviewable_id: self.id) if pending?
end