Class: Jobs::DeleteInaccessibleNotifications

Inherits:
Base
  • Object
show all
Defined in:
app/jobs/regular/delete_inaccessible_notifications.rb

Instance Method Summary collapse

Methods inherited from Base

acquire_cluster_concurrency_lock!, clear_cluster_concurrency_lock!, cluster_concurrency, cluster_concurrency_redis_key, delayed_perform, #error_context, get_cluster_concurrency, #last_db_duration, #log, #perform, #perform_immediately

Instance Method Details

#execute(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'app/jobs/regular/delete_inaccessible_notifications.rb', line 5

def execute(args)
  raise Discourse::InvalidParameters.new(:topic_id) if args[:topic_id].blank?

  Notification
    .where(topic_id: args[:topic_id])
    .find_each do |notification|
      next unless notification.user && notification.topic

      notification.destroy if !Guardian.new(notification.user).can_see?(notification.topic)
    end
end