parent
ef2b924679
commit
6d98a73180
@ -1,15 +1,16 @@ |
|||||||
# frozen_string_literal: true |
# frozen_string_literal: true |
||||||
|
|
||||||
class BlockDomainService < BaseService |
class BlockDomainService < BaseService |
||||||
def call(domain) |
def call(domain, severity) |
||||||
DomainBlock.find_or_create_by!(domain: domain) |
DomainBlock.where(domain: domain).first_or_create!(domain: domain, severity: severity) |
||||||
|
|
||||||
Account.where(domain: domain).find_each do |account| |
if severity == :silence |
||||||
if account.subscribed? |
Account.where(domain: domain).update_all(silenced: true) |
||||||
account.subscription(api_subscription_url(account.id)).unsubscribe |
else |
||||||
|
Account.where(domain: domain).find_each do |account| |
||||||
|
account.subscription(api_subscription_url(account.id)).unsubscribe if account.subscribed? |
||||||
|
SuspendAccountService.new.call(account) |
||||||
end |
end |
||||||
|
|
||||||
account.destroy! |
|
||||||
end |
end |
||||||
end |
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