FEATURE: Deleting a user with their posts also deletes chat messages. (#19194)

This commit introduce a new API for registering callbacks, which we'll execute when a user gets destroyed, and the `delete_posts` opt is true. The chat plugin registers one callback and queues a job to destroy every message from that user in batches.
This commit is contained in:
Roman Rizzi
2022-11-28 13:32:57 -03:00
committed by GitHub
parent 7dfe85fcc7
commit 07a9163ea8
14 changed files with 219 additions and 80 deletions

View File

@ -1138,6 +1138,17 @@ class Plugin::Instance
HashtagAutocompleteService.register_type_in_context(type, context, priority)
end
##
# Register a block that will be called when the UserDestroyer runs
# with the :delete_posts opt set to true. It's important to note that the block will
# execute before any other :delete_posts actions, it allows us to manipulate flags
# before agreeing with them. For example, discourse-akismet makes use of this
#
# @param {Block} callback to be called with the user, guardian, and the destroyer opts as arguments
def register_user_destroyer_on_content_deletion_callback(callback)
DiscoursePluginRegistry.register_user_destroyer_on_content_deletion_callback(callback, self)
end
protected
def self.js_path