parent
a77a081c63
commit
77a76d5171
@ -1,15 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class BlockDomainService < BaseService
|
||||
def call(domain)
|
||||
DomainBlock.find_or_create_by!(domain: domain)
|
||||
def call(domain, severity)
|
||||
DomainBlock.where(domain: domain).first_or_create!(domain: domain, severity: severity)
|
||||
|
||||
if severity == :silence
|
||||
Account.where(domain: domain).update_all(silenced: true)
|
||||
else
|
||||
Account.where(domain: domain).find_each do |account|
|
||||
if account.subscribed?
|
||||
account.subscription(api_subscription_url(account.id)).unsubscribe
|
||||
account.subscription(api_subscription_url(account.id)).unsubscribe if account.subscribed?
|
||||
SuspendAccountService.new.call(account)
|
||||
end
|
||||
|
||||
account.destroy!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,5 @@
|
||||
class AddSeverityToDomainBlocks < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :domain_blocks, :severity, :integer, default: 0
|
||||
end
|
||||
end
|
Loading…
Reference in new issue