Browse Source

Fix crash when encountering invalid account fields (#16598)

* Add test

* Fix crash when encountering invalid account fields
closed-social-v3
Claire 3 years ago
committed by Eugen Rochko
parent
commit
4f852448e1
2 changed files with 6 additions and 1 deletions
  1. +5
    -1
      app/models/account.rb
  2. +1
    -0
      spec/services/activitypub/process_account_service_spec.rb

+ 5
- 1
app/models/account.rb View File

@ -295,7 +295,11 @@ class Account < ApplicationRecord
end
def fields
(self[:fields] || []).map { |f| Field.new(self, f) }
(self[:fields] || []).map do |f|
Field.new(self, f)
rescue
nil
end.compact
end
def fields_attributes=(attributes)

+ 1
- 0
spec/services/activitypub/process_account_service_spec.rb View File

@ -12,6 +12,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
attachment: [
{ type: 'PropertyValue', name: 'Pronouns', value: 'They/them' },
{ type: 'PropertyValue', name: 'Occupation', value: 'Unit test' },
{ type: 'PropertyValue', name: 'non-string', value: ['foo', 'bar'] },
],
}.with_indifferent_access
end

Loading…
Cancel
Save