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

@@ -83,6 +83,25 @@ RSpec.describe ReviewableFlaggedPost, type: :model do
expect(reviewable.actions_for(guardian).has?(:agree_and_silence)).to eq(false)
expect(reviewable.actions_for(guardian).has?(:agree_and_suspend)).to eq(false)
end
context "when flagged as potential_spam" do
before { reviewable.update!(potential_spam: true) }
it "excludes delete action if the reviewer cannot delete the user" do
post.user.user_stat.update!(
first_post_created_at: 1.year.ago,
post_count: User::MAX_STAFF_DELETE_POST_COUNT + 1
)
expect(reviewable.actions_for(guardian).has?(:delete_user)).to be false
expect(reviewable.actions_for(guardian).has?(:delete_user_block)).to be false
end
it "includes delete actions if the reviewer can delete the user" do
expect(reviewable.actions_for(guardian).has?(:delete_user)).to be true
expect(reviewable.actions_for(guardian).has?(:delete_user_block)).to be true
end
end
end
it "agree_and_keep agrees with the flags and keeps the post" do