Merge branch 'master' into glitch-soc/merge-upstream

This commit is contained in:
Claire
2020-12-21 18:28:23 +01:00
8 changed files with 89 additions and 61 deletions

View File

@@ -25,7 +25,7 @@ class Poll < ApplicationRecord
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

View File

@@ -83,7 +83,7 @@ class User < ApplicationRecord
has_one :invite_request, class_name: 'UserInviteRequest', inverse_of: :user, dependent: :destroy
accepts_nested_attributes_for :invite_request, reject_if: ->(attributes) { attributes['text'].blank? && !Setting.require_invite_text }
validates :invite_request, presence: true, on: :create, if: -> { Setting.require_invite_text }
validates :invite_request, presence: true, on: :create, if: -> { Setting.require_invite_text && !invited? }
validates :locale, inclusion: I18n.available_locales.map(&:to_s), if: :locale?
validates_with BlacklistedEmailValidator, on: :create

View File

@@ -4,8 +4,6 @@ class BatchedRemoveStatusService < BaseService
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
@@ -19,7 +17,6 @@ class BatchedRemoveStatusService < BaseService
@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

View File

@@ -122,7 +122,11 @@ class DeleteAccountService < BaseService
@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, as long as we take care of
# notifications.
Notification.where(poll: poll).delete_all
poll.delete
end
associations_for_destruction.each do |association_name|

View File

@@ -3,7 +3,7 @@
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)