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
|
class REST::ProfileSerializer < ActiveModel::Serializer
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
include FormattingHelper
|
||||||
|
|
||||||
# Please update app/javascript/api_types/profile.ts when making changes to the attributes
|
# Please update app/javascript/api_types/profile.ts when making changes to the attributes
|
||||||
attributes :id, :display_name, :note, :fields,
|
attributes :id, :display_name, :note, :fields,
|
||||||
|
:formatted_note, :formatted_fields,
|
||||||
:avatar, :avatar_static, :avatar_description, :header, :header_static, :header_description,
|
:avatar, :avatar_static, :avatar_description, :header, :header_static, :header_description,
|
||||||
:locked, :bot,
|
:locked, :bot,
|
||||||
:hide_collections, :discoverable, :indexable,
|
:hide_collections, :discoverable, :indexable,
|
||||||
@ -17,10 +19,18 @@ class REST::ProfileSerializer < ActiveModel::Serializer
|
|||||||
object.id.to_s
|
object.id.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def formatted_note
|
||||||
|
account_bio_format(object)
|
||||||
|
end
|
||||||
|
|
||||||
def fields
|
def fields
|
||||||
object.fields.map(&:to_h)
|
object.fields.map(&:to_h)
|
||||||
end
|
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
|
def avatar
|
||||||
object.avatar_file_name.present? ? full_asset_url(object.avatar_original_url) : nil
|
object.avatar_file_name.present? ? full_asset_url(object.avatar_original_url) : nil
|
||||||
end
|
end
|
||||||
|
|||||||
@ -44,8 +44,10 @@ RSpec.describe 'Profile API' do
|
|||||||
'indexable' => account.indexable,
|
'indexable' => account.indexable,
|
||||||
'display_name' => account.display_name,
|
'display_name' => account.display_name,
|
||||||
'fields' => [],
|
'fields' => [],
|
||||||
|
'formatted_fields' => [],
|
||||||
'attribution_domains' => [],
|
'attribution_domains' => [],
|
||||||
'note' => account.note,
|
'note' => account.note,
|
||||||
|
'formatted_note' => account.note,
|
||||||
'show_featured' => account.show_featured,
|
'show_featured' => account.show_featured,
|
||||||
'show_media' => account.show_media,
|
'show_media' => account.show_media,
|
||||||
'show_media_replies' => account.show_media_replies,
|
'show_media_replies' => account.show_media_replies,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user