docbrown/app/services/users/delete_comments.rb
Molly Struve a396660986
Remove Comment and Article docs From Elasticsearch During User Delete (#7008)
* 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
2020-04-01 16:01:16 -04:00

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