0
0
Fork 0

Domain blocks now have varying severity - auto-suspend vs auto-silence

This commit is contained in:
Eugen Rochko 2017-01-23 17:38:38 +01:00
parent ef2b924679
commit 6d98a73180
8 changed files with 25 additions and 12 deletions

View file

@ -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)
Account.where(domain: domain).find_each do |account|
if account.subscribed?
account.subscription(api_subscription_url(account.id)).unsubscribe
if severity == :silence
Account.where(domain: domain).update_all(silenced: true)
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
account.destroy!
end
end
end