about summary refs log tree commit diff
path: root/app/models/account.rb
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-05-10 03:48:11 -0500
committermultiple creatures <dev@multiple-creature.party>2019-05-21 03:16:23 -0500
commit3b06175e8f5cb9d688e8ec376dbfd88abf5f3278 (patch)
tree160a6f6c97777ca022326bb93701f358fe689c99 /app/models/account.rb
parent5c59d1837f2d3152342ef45bf7827495183e62dd (diff)
Moderation: add `force sensitive` and `force unlisted` actions. Accounts: add federatable `adult content` tag. Handle from remote accounts as well.
Diffstat (limited to 'app/models/account.rb')
-rw-r--r--app/models/account.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 6e7cf3773..5f88a951f 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -48,6 +48,9 @@
 #  vars                    :jsonb            not null
 #  replies                 :boolean          default(TRUE), not null
 #  unlisted                :boolean          default(FALSE), not null
+#  force_unlisted          :boolean          default(FALSE), not null
+#  force_sensitive         :boolean          default(FALSE), not null
+#  adults_only             :boolean          default(FALSE), not null
 #
 
 class Account < ApplicationRecord
@@ -120,6 +123,7 @@ class Account < ApplicationRecord
            :moderator?,
            :staff?,
            :locale,
+           :default_sensitive?,
            :hides_network?,
            :shows_application?,
            :always_local?,
@@ -185,6 +189,28 @@ class Account < ApplicationRecord
     ResolveAccountService.new.call(acct)
   end
 
+  def force_unlisted!
+    transaction do
+      update!(force_unlisted: true)
+      Status.where(account_id: id, visibility: :public).in_batches.update_all(visibility: :unlisted)
+    end
+  end
+
+  def force_sensitive!
+    transaction do
+      update!(force_sensitive: true)
+      Status.where(account_id: id, sensitive: false).in_batches.update_all(sensitive: true)
+    end
+  end
+
+  def allow_public!
+    update!(force_unlisted: false)
+  end
+
+  def allow_nonsensitive!
+    update!(force_sensitive: false)
+  end
+
   def silenced?
     silenced_at.present?
   end