mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: notifications are missing under certain conditions
This simplifies the code for refreshing notification counts. It now unconditionally looks up the user object which protects against stale objects in memory. This also removes a pile of conditional logic we no longer need.
This commit is contained in:
@@ -217,15 +217,8 @@ class Notification < ActiveRecord::Base
|
||||
protected
|
||||
|
||||
def refresh_notification_count
|
||||
begin
|
||||
if user.has_attribute?(:seen_notification_id)
|
||||
user.notifications.reset
|
||||
user.publish_notifications_state
|
||||
else
|
||||
User.find_by(id: user.id).publish_notifications_state
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
# happens when we delete a user
|
||||
if user_id
|
||||
User.find_by(id: user_id)&.publish_notifications_state
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user