mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
FIX: Destroy notifications and sync notifications count in transaction.
* Seeing errors where the user is destroyed right when the call to reload is made.
This commit is contained in:
parent
755b511b5c
commit
9d307a9977
@ -178,13 +178,15 @@ class PostAlerter
|
||||
return if user.blank?
|
||||
return unless Guardian.new(user).can_see?(topic)
|
||||
|
||||
user.notifications.where(
|
||||
notification_type: types,
|
||||
topic_id: topic.id
|
||||
).destroy_all
|
||||
User.transaction do
|
||||
user.notifications.where(
|
||||
notification_type: types,
|
||||
topic_id: topic.id
|
||||
).destroy_all
|
||||
|
||||
# HACK so notification counts sync up correctly
|
||||
user.reload
|
||||
# Reload so notification counts sync up correctly
|
||||
user.reload
|
||||
end
|
||||
end
|
||||
|
||||
NOTIFIABLE_TYPES = [:mentioned, :replied, :quoted, :posted, :linked, :private_message, :group_mentioned].map { |t|
|
||||
|
Loading…
Reference in New Issue
Block a user