diff options
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/after_block_service.rb | 32 | ||||
-rw-r--r-- | app/services/remove_status_service.rb | 2 |
2 files changed, 24 insertions, 10 deletions
diff --git a/app/services/after_block_service.rb b/app/services/after_block_service.rb index 70e6467c7..b39c8b591 100644 --- a/app/services/after_block_service.rb +++ b/app/services/after_block_service.rb @@ -8,8 +8,9 @@ class AfterBlockService < BaseService clear_home_feed! clear_notifications! clear_conversations! - unlink_replies! - unlink_mentions! + + defederate_interactions! + unlink_interactions! end private @@ -26,15 +27,26 @@ class AfterBlockService < BaseService Notification.where(account: @account).where(from_account: @target_account).in_batches.delete_all end - def unlink_replies! - @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) + def unlink_interactions! + @target_account.statuses.where(in_reply_to_account_id: @account.id).in_batches.update_all(in_reply_to_account_id: nil) + @target_account.mentions.where(account_id: @account.id).in_batches.destroy_all + end + + def defederate_interactions! + defederate_statuses!(@account.statuses.where(in_reply_to_account_id: @target_account.id)) + defederate_statuses!(@account.statuses.joins(:mentions).where(mentions: { account_id: @target_account.id })) + defederate_statuses!(@account.statuses.joins(:reblog).where(reblogs_statuses: { account_id: @target_account.id })) + defederate_favourites! + end + + def defederate_statuses!(statuses) + statuses.find_each { |status| RemovalWorker.perform_async(status.id, unpublish: true, blocking: @target_account.id) } end - def unlink_mentions! - @account.mentions.where(account_id: @target_account.id) - .or(@target_account.mentions.where(account_id: @account.id)) - .in_batches.destroy_all + def defederate_favourites! + favourites = @account.favourites.joins(:status).where(statuses: { account_id: @target_account.id }) + favourites.select(:status_id).find_each do |favourite| + UnfavouriteWorker.perform_async(@account.id, favourite.status_id) + end end end diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb index c0055882d..4d07632d3 100644 --- a/app/services/remove_status_service.rb +++ b/app/services/remove_status_service.rb @@ -50,6 +50,8 @@ class RemoveStatusService < BaseService remove_from_remote_affected remove_from_remote_shared + @status.mentions.where(account_id: @options[:blocking]).destroy_all if @options[:blocking] + return unless @options[:unpublish] @status.update(published: false, expires_at: nil, local_only: @status.local?) |