mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Skip notifications without topic_id in ensure_consistency (#16299)
This commit is contained in:
committed by
GitHub
parent
2e77cc86fc
commit
b974375239
@@ -64,7 +64,7 @@ class Notification < ActiveRecord::Base
|
|||||||
DELETE
|
DELETE
|
||||||
FROM notifications n
|
FROM notifications n
|
||||||
WHERE high_priority
|
WHERE high_priority
|
||||||
AND notification_type NOT IN (#{types[:chat_mention].to_i}, #{types[:chat_message].to_i})
|
AND n.topic_id IS NOT NULL
|
||||||
AND NOT EXISTS (
|
AND NOT EXISTS (
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM posts p
|
FROM posts p
|
||||||
|
|||||||
@@ -340,10 +340,9 @@ describe Notification do
|
|||||||
expect(Notification.count).to eq(2)
|
expect(Notification.count).to eq(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not delete chat_message notifications' do
|
it 'does not delete notifications that do not have a topic_id' do
|
||||||
Notification.create!(read: false, user_id: user.id, topic_id: nil, post_number: nil, data: '[]',
|
Notification.create!(read: false, user_id: user.id, topic_id: nil, post_number: nil, data: '[]',
|
||||||
notification_type: Notification.types[:chat_mention])
|
notification_type: Notification.types[:chat_mention], high_priority: true)
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
Notification.ensure_consistency!
|
Notification.ensure_consistency!
|
||||||
}.to_not change { Notification.count }
|
}.to_not change { Notification.count }
|
||||||
|
|||||||
Reference in New Issue
Block a user