2019-07-22 12:02:21 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Jobs
|
2019-10-01 23:01:53 -05:00
|
|
|
class DeleteInaccessibleNotifications < ::Jobs::Base
|
2019-07-22 12:02:21 -05:00
|
|
|
def execute(args)
|
|
|
|
raise Discourse::InvalidParameters.new(:topic_id) if args[:topic_id].blank?
|
|
|
|
|
2023-01-09 06:20:10 -06:00
|
|
|
Notification
|
|
|
|
.where(topic_id: args[:topic_id])
|
|
|
|
.find_each do |notification|
|
|
|
|
next unless notification.user && notification.topic
|
2019-07-22 12:02:21 -05:00
|
|
|
|
2023-01-09 06:20:10 -06:00
|
|
|
notification.destroy if !Guardian.new(notification.user).can_see?(notification.topic)
|
2019-07-22 12:02:21 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|