logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

export.rb (774B)


  1. # frozen_string_literal: true
  2. require 'csv'
  3. class Export
  4. attr_reader :account
  5. def initialize(account)
  6. @account = account
  7. end
  8. def to_blocked_accounts_csv
  9. to_csv account.blocking
  10. end
  11. def to_muted_accounts_csv
  12. to_csv account.muting
  13. end
  14. def to_following_accounts_csv
  15. to_csv account.following
  16. end
  17. def total_storage
  18. account.media_attachments.sum(:file_file_size)
  19. end
  20. def total_follows
  21. account.following.count
  22. end
  23. def total_blocks
  24. account.blocking.count
  25. end
  26. def total_mutes
  27. account.muting.count
  28. end
  29. private
  30. def to_csv(accounts)
  31. CSV.generate do |csv|
  32. accounts.each do |account|
  33. csv << [(account.local? ? account.local_username_and_domain : account.acct)]
  34. end
  35. end
  36. end
  37. end