docbrown/app/services/notifications/remove_each.rb
Andy Zhao cf8b4e37d3 Add context data to comment notifications (#3258)
* Add db relationship for comment and notifications

* Use delete instead of destroy

* Add comment's ancestors' data

* Delete descendant notification data appropriately

* Update notifications for comments up the tree as well

* Update descendant notifications appropriately

* Fix apostrophe edge case

* Make ancestor_data method private
2019-06-21 14:26:19 -04:00

24 lines
518 B
Ruby

module Notifications
class RemoveEach
# notifiable_collection_ids: an array of
# notifiable objects ids (eg mention)
def initialize(notifiable_collection_ids)
@notifiable_collection_ids = notifiable_collection_ids
end
def self.call(*args)
new(*args).call
end
def call
Notification.where(
notifiable_id: notifiable_collection_ids,
notifiable_type: "Mention",
).delete_all
end
private
attr_reader :notifiable_collection_ids
end
end