* remove comment and article docs when they are deleted * fix banish user spec to handle ES deletes * remove comments from elasticsearch when deleted via delete comments service
18 lines
445 B
Ruby
18 lines
445 B
Ruby
module Users
|
|
module DeleteComments
|
|
module_function
|
|
|
|
def call(user, cache_buster = CacheBuster)
|
|
return unless user.comments.any?
|
|
|
|
user.comments.find_each do |comment|
|
|
comment.reactions.delete_all
|
|
cache_buster.bust_comment(comment.commentable)
|
|
comment.remove_notifications
|
|
comment.remove_from_elasticsearch
|
|
comment.delete
|
|
end
|
|
cache_buster.bust_user(user)
|
|
end
|
|
end
|
|
end
|