about summary refs log tree commit diff
path: root/app/services/activitypub/process_account_service.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/services/activitypub/process_account_service.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/services/activitypub/process_account_service.rb')
-rw-r--r--app/services/activitypub/process_account_service.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb
index f36ab7d61..ee24718e1 100644
--- a/app/services/activitypub/process_account_service.rb
+++ b/app/services/activitypub/process_account_service.rb
@@ -48,11 +48,13 @@ class ActivityPub::ProcessAccountService < BaseService
 
   def create_account
     @account = Account.new
-    @account.username     = @username
-    @account.domain       = @domain
-    @account.private_key  = nil
-    @account.suspended_at = domain_block.created_at if auto_suspend?
-    @account.silenced_at = domain_block.created_at if auto_silence?
+    @account.username         = @username
+    @account.domain           = @domain
+    @account.private_key      = nil
+    @account.suspended_at     = domain_block.created_at if auto_suspend?
+    @account.silenced_at      = domain_block.created_at if auto_silence?
+    @account.force_unlisted   = true if force_unlisted?
+    @account.force_sensitive  = true if force_sensitive?
   end
 
   def update_account
@@ -75,6 +77,7 @@ class ActivityPub::ProcessAccountService < BaseService
     @account.display_name            = @json['name'] || ''
     @account.note                    = @json['summary'] || ''
     @account.locked                  = @json['manuallyApprovesFollowers'] || false
+    @account.adults_only             = @json['suggestedMinAge'].to_i >= 18
     @account.fields                  = property_values || {}
     @account.also_known_as           = as_array(@json['alsoKnownAs'] || []).map { |item| value_or_id(item) }
     @account.actor_type              = actor_type
@@ -195,6 +198,14 @@ class ActivityPub::ProcessAccountService < BaseService
     domain_block&.silence?
   end
 
+  def auto_force_unlisted?
+    domain_block&.force_unlisted?
+  end
+
+  def auto_force_sensitive?
+    domain_block&.force_sensitive?
+  end
+
   def domain_block
     return @domain_block if defined?(@domain_block)
     @domain_block = DomainBlock.find_by(domain: @domain)