belongs_to :account
belongs_to :status
- has_many :votes, class_name: 'PollVote', inverse_of: :poll, dependent: :destroy
+ has_many :votes, class_name: 'PollVote', inverse_of: :poll, dependent: :delete_all
has_many :notifications, as: :activity, dependent: :destroy
belongs_to :thread, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :replies, optional: true
belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs, optional: true
- has_many :favourites, inverse_of: :status, dependent: :destroy
+ has_many :favourites, inverse_of: :status, dependent: :delete_all
has_many :bookmarks, inverse_of: :status, dependent: :destroy
has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblog, dependent: :destroy
has_many :replies, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :thread
include Redisable
# Delete given statuses and reblogs of them
- # Dispatch PuSH updates of the deleted statuses, but only local ones
- # Dispatch Salmon deletes, unique per domain, of the deleted statuses, but only local ones
# Remove statuses from home feeds
# Push delete events to streaming API for home feeds and public feeds
# @param [Enumerable<Status>] statuses A preferably batched array of statuses
@json_payloads = statuses.each_with_object({}) { |s, h| h[s.id] = Oj.dump(event: :delete, payload: s.id.to_s) }
- # Ensure that rendered XML reflects destroyed state
statuses.each do |status|
status.mark_for_mass_destruction!
status.destroy
@account.polls.reorder(nil).find_each do |poll|
next if @options[:reserve_username] && reported_status_ids.include?(poll.status_id)
- poll.destroy
+ # We can safely delete the poll rather than destroy it, as any non-reported
+ # status should have been deleted already
+ poll.delete
end
associations_for_destruction.each do |association_name|
class AccountDeletionWorker
include Sidekiq::Worker
- sidekiq_options queue: 'pull'
+ sidekiq_options queue: 'pull', lock: :until_executed
def perform(account_id, options = {})
reserve_username = options.with_indifferent_access.fetch(:reserve_username, true)