about summary refs log tree commit diff
path: root/app/models/export.rb
diff options
context:
space:
mode:
authorpluralcafe-docker <git@plural.cafe>2019-01-04 21:19:55 +0000
committerpluralcafe-docker <git@plural.cafe>2019-01-04 21:19:55 +0000
commit74134e490c49d8a7d88cc69720e22cd88cee9233 (patch)
treebd7fc8d41f7887037401ff86c81bc93d5fb00d01 /app/models/export.rb
parent797a8429a0deb511e6d6092edad39f856231534e (diff)
parent0acd51acdc1e670bf57f58671cb8e30743782c63 (diff)
Merge branch 'glitch'
Diffstat (limited to 'app/models/export.rb')
-rw-r--r--app/models/export.rb38
1 files changed, 34 insertions, 4 deletions
diff --git a/app/models/export.rb b/app/models/export.rb
index 0eeac0dc0..a2520e9c2 100644
--- a/app/models/export.rb
+++ b/app/models/export.rb
@@ -9,15 +9,33 @@ class Export
   end
 
   def to_blocked_accounts_csv
-    to_csv account.blocking
+    to_csv account.blocking.select(:username, :domain)
   end
 
   def to_muted_accounts_csv
-    to_csv account.muting
+    to_csv account.muting.select(:username, :domain)
   end
 
   def to_following_accounts_csv
-    to_csv account.following
+    to_csv account.following.select(:username, :domain)
+  end
+
+  def to_lists_csv
+    CSV.generate do |csv|
+      account.owned_lists.select(:title).each do |list|
+        list.accounts.select(:username, :domain).each do |account|
+          csv << [list.title, acct(account)]
+        end
+      end
+    end
+  end
+
+  def to_blocked_domains_csv
+    CSV.generate do |csv|
+      account.domain_blocks.pluck(:domain).each do |domain|
+        csv << [domain]
+      end
+    end
   end
 
   def total_storage
@@ -32,6 +50,10 @@ class Export
     account.following_count
   end
 
+  def total_lists
+    account.owned_lists.count
+  end
+
   def total_followers
     account.followers_count
   end
@@ -44,13 +66,21 @@ class Export
     account.muting.count
   end
 
+  def total_domain_blocks
+    account.domain_blocks.count
+  end
+
   private
 
   def to_csv(accounts)
     CSV.generate do |csv|
       accounts.each do |account|
-        csv << [(account.local? ? account.local_username_and_domain : account.acct)]
+        csv << [acct(account)]
       end
     end
   end
+
+  def acct(account)
+    account.local? ? account.local_username_and_domain : account.acct
+  end
 end