mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -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 if user.blank?
|
||||||
return unless Guardian.new(user).can_see?(topic)
|
return unless Guardian.new(user).can_see?(topic)
|
||||||
|
|
||||||
user.notifications.where(
|
User.transaction do
|
||||||
notification_type: types,
|
user.notifications.where(
|
||||||
topic_id: topic.id
|
notification_type: types,
|
||||||
).destroy_all
|
topic_id: topic.id
|
||||||
|
).destroy_all
|
||||||
|
|
||||||
# HACK so notification counts sync up correctly
|
# Reload so notification counts sync up correctly
|
||||||
user.reload
|
user.reload
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
NOTIFIABLE_TYPES = [:mentioned, :replied, :quoted, :posted, :linked, :private_message, :group_mentioned].map { |t|
|
NOTIFIABLE_TYPES = [:mentioned, :replied, :quoted, :posted, :linked, :private_message, :group_mentioned].map { |t|
|
||||||
|
Loading…
Reference in New Issue
Block a user