A platform for community discussion. Free, open, simple.
FIX: Destroy notifications and sync notifications count in transaction.
Guo Xiang Tan9d307a99773e
diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rbindex 748d4d0b2d7..05e72dab601 100644--- a/app/services/post_alerter.rb+++ b/app/services/post_alerter.rb@@ -178,13 +178,15 @@ class PostAlerterreturn if user.blank?return unless Guardian.new(user).can_see?(topic)- user.notifications.where(- notification_type: types,- topic_id: topic.id- ).destroy_all-- # HACK so notification counts sync up correctly- user.reload+ User.transaction do+ user.notifications.where(+ notification_type: types,+ topic_id: topic.id+ ).destroy_all++ # Reload so notification counts sync up correctly+ user.reload+ endendNOTIFIABLE_TYPES = [:mentioned, :replied, :quoted, :posted, :linked, :private_message, :group_mentioned].map { |t|