about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-09-09 13:41:45 +0200
committerGitHub <noreply@github.com>2017-09-09 13:41:45 +0200
commit9e15eeec63b36f147700303961ad5ef207b81986 (patch)
tree29aa191614dea96ae04968767d82716ba72cd9a6
parent3c45d3963a21812f00318353be90010df636bd0d (diff)
Add missing reject_media check before avatar download via ActivityPub (#4862)
-rw-r--r--app/services/activitypub/process_account_service.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb
index c63577fe5..b54e447ad 100644
--- a/app/services/activitypub/process_account_service.rb
+++ b/app/services/activitypub/process_account_service.rb
@@ -48,14 +48,14 @@ class ActivityPub::ProcessAccountService < BaseService
     @account.url                 = url || @uri
     @account.display_name        = @json['name'] || ''
     @account.note                = @json['summary'] || ''
-    @account.avatar_remote_url   = image_url('icon')
-    @account.header_remote_url   = image_url('image')
+    @account.avatar_remote_url   = image_url('icon')  unless skip_download?
+    @account.header_remote_url   = image_url('image') unless skip_download?
     @account.public_key          = public_key || ''
     @account.locked              = @json['manuallyApprovesFollowers'] || false
     @account.statuses_count      = outbox_total_items    if outbox_total_items.present?
     @account.following_count     = following_total_items if following_total_items.present?
     @account.followers_count     = followers_total_items if followers_total_items.present?
-    @account.save!
+    @account.save_with_optional_media!
   end
 
   def upgrade_account
@@ -115,6 +115,10 @@ class ActivityPub::ProcessAccountService < BaseService
     @collections[type] = nil
   end
 
+  def skip_download?
+    @account.suspended? || domain_block&.reject_media?
+  end
+
   def auto_suspend?
     domain_block && domain_block.suspend?
   end