mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-15 12:44:24 -05:00
90f12f2e5a
* Add focus param to media API, center thumbnails on focus point * Add UI for setting a focal point * Improve focal point icon on upload item * Use focal point in upload preview * Add focalPoint property to ActivityPub * Don't show focal point button for non-image attachments
39 lines
1.4 KiB
Ruby
39 lines
1.4 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' },
|
|
},
|
|
],
|
|
}.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
|