mirror of
https://github.com/discourse/discourse.git
synced 2026-08-03 01:49:44 -05:00
FIX: Hide badge notifications for badges that have been deleted (#36990)
Follow-up to 121eb1b0f8
This commit is contained in:
@@ -255,11 +255,11 @@ class Notification < ActiveRecord::Base
|
||||
|
||||
return notifications if badge_ids.empty?
|
||||
|
||||
disabled_badge_ids = Badge.where(id: badge_ids, enabled: false).distinct.pluck(:id)
|
||||
enabled_badge_ids = Badge.where(id: badge_ids, enabled: true).pluck(:id).to_set
|
||||
|
||||
notifications.reject do |n|
|
||||
n.notification_type == types[:granted_badge] &&
|
||||
disabled_badge_ids.include?(n.data_hash[:badge_id])
|
||||
!enabled_badge_ids.include?(n.data_hash[:badge_id])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -892,5 +892,13 @@ RSpec.describe Notification do
|
||||
|
||||
expect(result).to contain_exactly(enabled_badge_notification, regular_notification)
|
||||
end
|
||||
|
||||
it "filters badge notifications for badges that do not exist" do
|
||||
enabled_badge.destroy!
|
||||
|
||||
result = Notification.filter_disabled_badge_notifications([enabled_badge_notification])
|
||||
|
||||
expect(result).to eq([])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user