about summary refs log tree commit diff
path: root/app/services/suspend_account_service.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-01-04 14:40:49 +0100
committerGitHub <noreply@github.com>2018-01-04 14:40:49 +0100
commit02ba03d6dba9e5633013e50366daabe573759168 (patch)
tree075aa39be96811563879369a45fb390293cbffa4 /app/services/suspend_account_service.rb
parent3bee0996c509f4b416096094061edbc9c10f5632 (diff)
Send one Delete of Actor in ActivityPub when account is suspended (#6172)
Diffstat (limited to 'app/services/suspend_account_service.rb')
-rw-r--r--app/services/suspend_account_service.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/services/suspend_account_service.rb b/app/services/suspend_account_service.rb
index 958b28cdc..56fa2d8dd 100644
--- a/app/services/suspend_account_service.rb
+++ b/app/services/suspend_account_service.rb
@@ -22,6 +22,8 @@ class SuspendAccountService < BaseService
   end
 
   def purge_content!
+    ActivityPub::RawDistributionWorker.perform_async(delete_actor_json, @account.id) if @account.local?
+
     @account.statuses.reorder(nil).find_in_batches do |statuses|
       BatchedRemoveStatusService.new.call(statuses)
     end
@@ -54,4 +56,14 @@ class SuspendAccountService < BaseService
   def destroy_all(association)
     association.in_batches.destroy_all
   end
+
+  def delete_actor_json
+    payload = ActiveModelSerializers::SerializableResource.new(
+      @account,
+      serializer: ActivityPub::DeleteActorSerializer,
+      adapter: ActivityPub::Adapter
+    ).as_json
+
+    Oj.dump(ActivityPub::LinkedDataSignature.new(payload).sign!(@account))
+  end
 end