mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-22 12:35:07 +01:00
78ed4ab75f
* Add bio fields - Fix #3211 - Fix #232 - Fix #121 * Display bio fields in web UI * Fix output of links and missing fields * Federate bio fields over ActivityPub as PropertyValue * Improve how the fields are stored, add to Edit profile form * Add rel=me to links in fields Fix #121
43 lines
1.6 KiB
Ruby
43 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class ActivityPub::Adapter < ActiveModelSerializers::Adapter::Base
|
|
CONTEXT = {
|
|
'@context': [
|
|
'https://www.w3.org/ns/activitystreams',
|
|
'https://w3id.org/security/v1',
|
|
|
|
{
|
|
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
|
|
'sensitive' => 'as:sensitive',
|
|
'movedTo' => 'as:movedTo',
|
|
'Hashtag' => 'as:Hashtag',
|
|
'ostatus' => 'http://ostatus.org#',
|
|
'atomUri' => 'ostatus:atomUri',
|
|
'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri',
|
|
'conversation' => 'ostatus:conversation',
|
|
'toot' => 'http://joinmastodon.org/ns#',
|
|
'Emoji' => 'toot:Emoji',
|
|
'focalPoint' => { '@container' => '@list', '@id' => 'toot:focalPoint' },
|
|
'featured' => 'toot:featured',
|
|
'schema' => 'http://schema.org#',
|
|
'PropertyValue' => 'schema:PropertyValue',
|
|
'value' => 'schema:value',
|
|
},
|
|
],
|
|
}.freeze
|
|
|
|
def self.default_key_transform
|
|
:camel_lower
|
|
end
|
|
|
|
def self.transform_key_casing!(value, _options)
|
|
ActivityPub::CaseTransform.camel_lower(value)
|
|
end
|
|
|
|
def serializable_hash(options = nil)
|
|
options = serialization_options(options)
|
|
serialized_hash = ActiveModelSerializers::Adapter::Attributes.new(serializer, instance_options).serializable_hash(options)
|
|
CONTEXT.merge(self.class.transform_key_casing!(serialized_hash, instance_options))
|
|
end
|
|
end
|