0
0
Fork 0

Add batch actions for approving and rejecting pending accounts (#10469)

This commit is contained in:
Eugen Rochko 2019-04-06 17:53:45 +02:00 committed by GitHub
parent 2c63e0292a
commit e1d0390e29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 130 additions and 3 deletions

View file

@ -2,6 +2,7 @@
class Form::AccountBatch
include ActiveModel::Model
include Authorization
attr_accessor :account_ids, :action, :current_account
@ -13,6 +14,10 @@ class Form::AccountBatch
remove_from_followers!
when 'block_domains'
block_domains!
when 'approve'
approve!
when 'reject'
reject!
end
end
@ -57,4 +62,18 @@ class Form::AccountBatch
ActivityPub::DeliveryWorker.perform_async(json, current_account.id, follow.account.inbox_url)
end
def approve!
users = accounts.includes(:user).map(&:user)
users.each { |user| authorize(user, :approve?) }
.each(&:approve!)
end
def reject!
records = accounts.includes(:user)
records.each { |account| authorize(account.user, :reject?) }
.each { |account| SuspendAccountService.new.call(account, including_user: true, destroy: true, skip_distribution: true) }
end
end