diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/account.rb | 1 | ||||
-rw-r--r-- | app/models/concerns/account_finder_concern.rb | 2 | ||||
-rw-r--r-- | app/models/export.rb | 6 | ||||
-rw-r--r-- | app/models/form/account_batch.rb | 19 |
4 files changed, 25 insertions, 3 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index 983d38e0e..a82251d2e 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -102,7 +102,6 @@ class Account < ApplicationRecord scope :tagged_with, ->(tag) { joins(:accounts_tags).where(accounts_tags: { tag_id: tag }) } scope :by_recent_status, -> { order(Arel.sql('(case when account_stats.last_status_at is null then 1 else 0 end) asc, account_stats.last_status_at desc')) } scope :popular, -> { order('account_stats.followers_count desc') } - scope :without_blocking, ->(account) { account.nil? ? all : where.not(id: Block.where(target_account_id: account.id).pluck(:account_id)) } delegate :email, :unconfirmed_email, diff --git a/app/models/concerns/account_finder_concern.rb b/app/models/concerns/account_finder_concern.rb index 7e3bbde09..0ac49cc12 100644 --- a/app/models/concerns/account_finder_concern.rb +++ b/app/models/concerns/account_finder_concern.rb @@ -13,7 +13,7 @@ module AccountFinderConcern end def representative - find_local(Setting.site_contact_username.gsub(/\A@/, '')) || Account.local.find_by(suspended: false) + find_local(Setting.site_contact_username.strip.gsub(/\A@/, '')) || Account.local.find_by(suspended: false) end def find_local(username) diff --git a/app/models/export.rb b/app/models/export.rb index b35632c60..cab01f11a 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -22,7 +22,11 @@ class Export end def to_following_accounts_csv - to_csv account.following.select(:username, :domain) + CSV.generate(headers: ['Account address', 'Show boosts'], write_headers: true) do |csv| + account.active_relationships.includes(:target_account).reorder(id: :desc).each do |follow| + csv << [acct(follow.target_account), follow.show_reblogs] + end + end end def to_lists_csv diff --git a/app/models/form/account_batch.rb b/app/models/form/account_batch.rb index 60eaaf0e2..5bc44e809 100644 --- a/app/models/form/account_batch.rb +++ b/app/models/form/account_batch.rb @@ -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 |