0
0
Fork 0

Refactor domain_blocks_controller (#2843)

* Set domain_block by before_action

* Cast value with ActiveRecord::Type

* Batch update
This commit is contained in:
alpaca-tc 2017-05-07 00:03:34 +09:00 committed by Eugen Rochko
parent 2d45794956
commit a0b1951791
3 changed files with 13 additions and 8 deletions

View file

@ -3,10 +3,12 @@
class UnblockDomainService < BaseService
def call(domain_block, retroactive)
if retroactive
accounts = Account.where(domain: domain_block.domain).in_batches
if domain_block.silence?
Account.where(domain: domain_block.domain).update_all(silenced: false)
accounts.update_all(silenced: false)
else
Account.where(domain: domain_block.domain).update_all(suspended: false)
accounts.update_all(suspended: false)
end
end