* 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
24 lines
518 B
Ruby
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
|