Fix reblogs being discarded after the reblogged status (#19731)
parent
e02812d5b6
commit
c2170991c7
|
@ -77,7 +77,7 @@ class Api::V1::StatusesController < Api::BaseController
|
|||
@status = Status.where(account: current_account).find(params[:id])
|
||||
authorize @status, :destroy?
|
||||
|
||||
@status.discard
|
||||
@status.discard_with_reblogs
|
||||
StatusPin.find_by(status: @status)&.destroy
|
||||
@status.account.statuses_count = @status.account.statuses_count - 1
|
||||
json = render_to_body json: @status, serializer: REST::StatusSerializer, source_requested: true
|
||||
|
|
|
@ -55,7 +55,7 @@ class StatusReachFinder
|
|||
|
||||
# Beware: Reblogs can be created without the author having had access to the status
|
||||
def reblogs_account_ids
|
||||
@status.reblogs.pluck(:account_id) if distributable? || unsafe?
|
||||
@status.reblogs.rewhere(deleted_at: [nil, @status.deleted_at]).pluck(:account_id) if distributable? || unsafe?
|
||||
end
|
||||
|
||||
# Beware: Favourites can be created without the author having had access to the status
|
||||
|
|
|
@ -44,7 +44,7 @@ class Admin::StatusBatchAction
|
|||
|
||||
ApplicationRecord.transaction do
|
||||
statuses.each do |status|
|
||||
status.discard
|
||||
status.discard_with_reblogs
|
||||
log_action(:destroy, status)
|
||||
end
|
||||
|
||||
|
|
|
@ -440,6 +440,12 @@ class Status < ApplicationRecord
|
|||
im
|
||||
end
|
||||
|
||||
def discard_with_reblogs
|
||||
discard_time = Time.current
|
||||
Status.unscoped.where(reblog_of_id: id, deleted_at: [nil, deleted_at]).in_batches.update_all(deleted_at: discard_time) unless reblog?
|
||||
update_attribute(:deleted_at, discard_time)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_status_stat!(attrs)
|
||||
|
|
|
@ -14,7 +14,7 @@ class AccountStatusesCleanupService < BaseService
|
|||
last_deleted = nil
|
||||
|
||||
account_policy.statuses_to_delete(budget, cutoff_id, account_policy.last_inspected).reorder(nil).find_each(order: :asc) do |status|
|
||||
status.discard
|
||||
status.discard_with_reblogs
|
||||
RemovalWorker.perform_async(status.id, { 'redraft' => false })
|
||||
num_deleted += 1
|
||||
last_deleted = status.id
|
||||
|
|
|
@ -19,7 +19,7 @@ class RemoveStatusService < BaseService
|
|||
@options = options
|
||||
|
||||
with_lock("distribute:#{@status.id}") do
|
||||
@status.discard
|
||||
@status.discard_with_reblogs
|
||||
|
||||
StatusPin.find_by(status: @status)&.destroy
|
||||
|
||||
|
@ -102,7 +102,7 @@ class RemoveStatusService < BaseService
|
|||
# because once original status is gone, reblogs will disappear
|
||||
# without us being able to do all the fancy stuff
|
||||
|
||||
@status.reblogs.includes(:account).reorder(nil).find_each do |reblog|
|
||||
@status.reblogs.rewhere(deleted_at: [nil, @status.deleted_at]).includes(:account).reorder(nil).find_each do |reblog|
|
||||
RemoveStatusService.new.call(reblog, original_removed: true)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue