about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-06-14 18:01:27 +0200
committerGitHub <noreply@github.com>2017-06-14 18:01:27 +0200
commit4a618908e836ecb94f70e99f2198ee7b3ba3b2ec (patch)
treef2a02c2deaf9c1af2b53dae705cc652f83e08db7 /app/services
parenta208e7d65581168cda04be543742f302a162ac1a (diff)
Account deletion (#3728)
* Add form for account deletion

* If avatar or header are gone from source, remove them

* Add option to have SuspendAccountService remove user record, add tests

* Exclude suspended accounts from search
Diffstat (limited to 'app/services')
-rw-r--r--app/services/suspend_account_service.rb7
-rw-r--r--app/services/update_remote_profile_service.rb15
2 files changed, 19 insertions, 3 deletions
diff --git a/app/services/suspend_account_service.rb b/app/services/suspend_account_service.rb
index 4a4f23b80..842500259 100644
--- a/app/services/suspend_account_service.rb
+++ b/app/services/suspend_account_service.rb
@@ -1,9 +1,10 @@
 # frozen_string_literal: true
 
 class SuspendAccountService < BaseService
-  def call(account)
+  def call(account, remove_user = false)
     @account = account
 
+    purge_user if remove_user
     purge_content
     purge_profile
     unsubscribe_push_subscribers
@@ -11,6 +12,10 @@ class SuspendAccountService < BaseService
 
   private
 
+  def purge_user
+    @account.user.destroy
+  end
+
   def purge_content
     @account.statuses.reorder(nil).find_each do |status|
       # This federates out deletes to previous followers
diff --git a/app/services/update_remote_profile_service.rb b/app/services/update_remote_profile_service.rb
index c65f35867..49a907682 100644
--- a/app/services/update_remote_profile_service.rb
+++ b/app/services/update_remote_profile_service.rb
@@ -27,8 +27,19 @@ class UpdateRemoteProfileService < BaseService
     account.locked       = remote_profile.locked?
 
     if !account.suspended? && !DomainBlock.find_by(domain: account.domain)&.reject_media?
-      account.avatar_remote_url = remote_profile.avatar if remote_profile.avatar.present?
-      account.header_remote_url = remote_profile.header if remote_profile.header.present?
+      if remote_profile.avatar.present?
+        account.avatar_remote_url = remote_profile.avatar
+      else
+        account.avatar_remote_url = ''
+        account.avatar.destroy
+      end
+
+      if remote_profile.header.present?
+        account.header_remote_url = remote_profile.header
+      else
+        account.header_remote_url = ''
+        account.header.destroy
+      end
     end
   end
 end