docbrown/app/services/notifications/remove_all.rb
Lewis Sparlin ff5a94dbf3
Fix notifications not deleting because mentions already destroyed (#14987)
* Fix notifications not deleting because mentions already destroyed

* Fix spelling in spec

* Use rspec expect/to assertions for delete notification spec clarity

* resolve failing spec, and remove need for environment check 🎉
2021-10-14 09:41:10 -06:00

25 lines
555 B
Ruby

module Notifications
class RemoveAll
def initialize(notifiable_ids, notifiable_type)
return unless %w[Article Comment Mention].include?(notifiable_type) && notifiable_ids.present?
@notifiable_type = notifiable_type
@notifiable_ids = notifiable_ids
end
def self.call(...)
new(...).call
end
def call
Notification.where(
notifiable_type: notifiable_type,
notifiable_id: notifiable_ids,
).delete_all
end
private
attr_reader :notifiable_type, :notifiable_ids
end
end