Add formatted_note and formatted_fields to GET /api/v1/profile (#38339)
This commit is contained in:
parent
1fb5cb1e67
commit
3ebd3952a1
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user