You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
524 B

  1. # frozen_string_literal: true
  2. class BlockDomainService < BaseService
  3. def call(domain, severity)
  4. DomainBlock.where(domain: domain).first_or_create!(domain: domain, severity: severity)
  5. if severity == :silence
  6. Account.where(domain: domain).update_all(silenced: true)
  7. else
  8. Account.where(domain: domain).find_each do |account|
  9. account.subscription(api_subscription_url(account.id)).unsubscribe if account.subscribed?
  10. SuspendAccountService.new.call(account)
  11. end
  12. end
  13. end
  14. end