闭社主体 forked from https://github.com/tootsuite/mastodon
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.

46 lines
1.0 KiB

  1. # frozen_string_literal: true
  2. require 'csv'
  3. class Settings::ExportsController < ApplicationController
  4. layout 'admin'
  5. before_action :authenticate_user!
  6. before_action :set_account
  7. def show
  8. @total_storage = current_account.media_attachments.sum(:file_file_size)
  9. @total_follows = current_account.following.count
  10. @total_blocks = current_account.blocking.count
  11. end
  12. def download_following_list
  13. @accounts = current_account.following
  14. respond_to do |format|
  15. format.csv { render text: accounts_list_to_csv(@accounts) }
  16. end
  17. end
  18. def download_blocking_list
  19. @accounts = current_account.blocking
  20. respond_to do |format|
  21. format.csv { render text: accounts_list_to_csv(@accounts) }
  22. end
  23. end
  24. private
  25. def set_account
  26. @account = current_user.account
  27. end
  28. def accounts_list_to_csv(list)
  29. CSV.generate do |csv|
  30. list.each do |account|
  31. csv << [(account.local? ? "#{account.username}@#{Rails.configuration.x.local_domain}" : account.acct)]
  32. end
  33. end
  34. end
  35. end