diff --git a/app/serializers/rest/profile_serializer.rb b/app/serializers/rest/profile_serializer.rb index b96daf87d4..79b620f0ac 100644 --- a/app/serializers/rest/profile_serializer.rb +++ b/app/serializers/rest/profile_serializer.rb @@ -2,9 +2,11 @@ class REST::ProfileSerializer < ActiveModel::Serializer include RoutingHelper + include FormattingHelper # Please update app/javascript/api_types/profile.ts when making changes to the attributes attributes :id, :display_name, :note, :fields, + :formatted_note, :formatted_fields, :avatar, :avatar_static, :avatar_description, :header, :header_static, :header_description, :locked, :bot, :hide_collections, :discoverable, :indexable, @@ -17,10 +19,18 @@ class REST::ProfileSerializer < ActiveModel::Serializer object.id.to_s end + def formatted_note + account_bio_format(object) + end + def fields object.fields.map(&:to_h) end + def formatted_fields + object.fields.map { |field| { name: field.name, value: account_field_value_format(field), verified_at: field.verified_at } } + end + def avatar object.avatar_file_name.present? ? full_asset_url(object.avatar_original_url) : nil end diff --git a/spec/requests/api/v1/profiles_spec.rb b/spec/requests/api/v1/profiles_spec.rb index 7d0d1a3622..0107b9c404 100644 --- a/spec/requests/api/v1/profiles_spec.rb +++ b/spec/requests/api/v1/profiles_spec.rb @@ -44,8 +44,10 @@ RSpec.describe 'Profile API' do 'indexable' => account.indexable, 'display_name' => account.display_name, 'fields' => [], + 'formatted_fields' => [], 'attribution_domains' => [], 'note' => account.note, + 'formatted_note' => account.note, 'show_featured' => account.show_featured, 'show_media' => account.show_media, 'show_media_replies' => account.show_media_replies,