diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/api/v1/statuses_controller.rb | 2 | ||||
-rw-r--r-- | app/lib/activitypub/activity/delete.rb | 2 | ||||
-rw-r--r-- | app/models/form/status_batch.rb | 2 | ||||
-rw-r--r-- | app/services/batched_remove_status_service.rb | 2 | ||||
-rw-r--r-- | app/services/remove_status_service.rb | 12 | ||||
-rw-r--r-- | app/workers/removal_worker.rb | 4 |
6 files changed, 18 insertions, 6 deletions
diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index 32f496f03..41fec1ad5 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -71,7 +71,7 @@ class Api::V1::StatusesController < Api::BaseController @status = Status.where(account_id: current_user.account).find(params[:id]) authorize @status, :destroy? - RemovalWorker.perform_async(@status.id) + RemovalWorker.perform_async(@status.id, redraft: true) render json: @status, serializer: REST::StatusSerializer, source_requested: true, monsterfork_api: monsterfork_api end diff --git a/app/lib/activitypub/activity/delete.rb b/app/lib/activitypub/activity/delete.rb index 5a962cd6a..8b9c21958 100644 --- a/app/lib/activitypub/activity/delete.rb +++ b/app/lib/activitypub/activity/delete.rb @@ -69,7 +69,7 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity end def delete_now! - RemoveStatusService.new.call(@status) + RemoveStatusService.new.call(@status, redraft: false) end def payload diff --git a/app/models/form/status_batch.rb b/app/models/form/status_batch.rb index 9d1d289de..3b82b5551 100644 --- a/app/models/form/status_batch.rb +++ b/app/models/form/status_batch.rb @@ -33,7 +33,7 @@ class Form::StatusBatch def delete_statuses Status.where(id: status_ids).reorder(nil).find_each do |status| - RemovalWorker.perform_async(status.id) + RemovalWorker.perform_async(status.id, redraft: false) Tombstone.find_or_create_by(uri: status.uri, account: status.account, by_moderator: true) log_action :destroy, status end diff --git a/app/services/batched_remove_status_service.rb b/app/services/batched_remove_status_service.rb index 09d094c15..7318831e7 100644 --- a/app/services/batched_remove_status_service.rb +++ b/app/services/batched_remove_status_service.rb @@ -6,7 +6,7 @@ class BatchedRemoveStatusService < BaseService # Delete given statuses and reblogs of them # Remove statuses from home feeds # Push delete events to streaming API for home feeds and public feeds - # @param [Status] statuses A preferably batched array of statuses + # @param [Enumerable<Status>] statuses A preferably batched array of statuses # @param [Hash] options # @option [Boolean] :skip_side_effects def call(statuses, **options) diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb index 51d200361..42ae9591d 100644 --- a/app/services/remove_status_service.rb +++ b/app/services/remove_status_service.rb @@ -6,6 +6,11 @@ class RemoveStatusService < BaseService MIN_SCHEDULE_OFFSET = 60.seconds.freeze + # Delete a status + # @param [Status] status + # @param [Hash] options + # @option [Boolean] :redraft + # @options [Boolean] :original_removed def call(status, **options) @payload = Oj.dump(event: :delete, payload: status.id.to_s) @status = status @@ -29,6 +34,7 @@ class RemoveStatusService < BaseService remove_from_media if status.media_attachments.any? remove_from_direct if status.direct_visibility? remove_from_spam_check + remove_media @status.destroy! else @@ -162,6 +168,12 @@ class RemoveStatusService < BaseService Redis.current.publish("timeline:direct:#{@account.id}", @payload) if @account.local? end + def remove_media + return if @options[:redraft] + + @status.media_attachments.destroy_all + end + def remove_from_spam_check redis.zremrangebyscore("spam_check:#{@status.account_id}", @status.id, @status.id) end diff --git a/app/workers/removal_worker.rb b/app/workers/removal_worker.rb index 19a660dd3..14423a4fb 100644 --- a/app/workers/removal_worker.rb +++ b/app/workers/removal_worker.rb @@ -3,8 +3,8 @@ class RemovalWorker include Sidekiq::Worker - def perform(status_id) - RemoveStatusService.new.call(Status.find(status_id)) + def perform(status_id, options = {}) + RemoveStatusService.new.call(Status.find(status_id), **options.symbolize_keys) rescue ActiveRecord::RecordNotFound true end |