diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-08-22 18:58:36 -0500 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-08-30 05:45:19 -0500 |
commit | 7ec22bd569c47adb7d82697228e5b785615cd1e2 (patch) | |
tree | 1f5ea50fd5bb969ad785736c66d60caa7b6ad62a /db/migrate/20200823002835_unlink_blocked_replies.rb | |
parent | 6c3a1729e38264d811c1ccbe25a91b7c9b04ba9d (diff) |
[Privacy] Unlink blocked replies
Diffstat (limited to 'db/migrate/20200823002835_unlink_blocked_replies.rb')
-rw-r--r-- | db/migrate/20200823002835_unlink_blocked_replies.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/db/migrate/20200823002835_unlink_blocked_replies.rb b/db/migrate/20200823002835_unlink_blocked_replies.rb new file mode 100644 index 000000000..6968fc93f --- /dev/null +++ b/db/migrate/20200823002835_unlink_blocked_replies.rb @@ -0,0 +1,28 @@ +class UnlinkBlockedReplies < ActiveRecord::Migration[5.2] + def up + Block.find_each do |block| + next if block.account.nil? || block.target_account.nil? + + unlink_replies!(block.account, block.target_account) + unlink_mentions!(block.account, block.target_account) + end + end + + def down + nil + end + + private + + def unlink_replies!(account, target_account) + target_account.statuses.where(in_reply_to_account_id: account.id) + .or(account.statuses.where(in_reply_to_account_id: target_account.id)) + .in_batches.update_all(in_reply_to_account_id: nil) + end + + def unlink_mentions!(account, target_account) + account.mentions.where(account_id: target_account.id) + .or(target_account.mentions.where(account_id: account.id)) + .in_batches.destroy_all + end +end |