2017-07-14 18:01:39 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ActivityPub::Adapter < ActiveModelSerializers::Adapter::Base
|
2017-09-02 05:01:23 -07:00
|
|
|
CONTEXT = {
|
|
|
|
'@context': [
|
|
|
|
'https://www.w3.org/ns/activitystreams',
|
|
|
|
'https://w3id.org/security/v1',
|
|
|
|
|
|
|
|
{
|
2017-09-02 14:13:35 -07:00
|
|
|
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
|
|
|
|
'sensitive' => 'as:sensitive',
|
2017-11-18 10:39:02 -08:00
|
|
|
'movedTo' => 'as:movedTo',
|
2017-09-02 14:13:35 -07:00
|
|
|
'Hashtag' => 'as:Hashtag',
|
|
|
|
'ostatus' => 'http://ostatus.org#',
|
|
|
|
'atomUri' => 'ostatus:atomUri',
|
|
|
|
'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri',
|
|
|
|
'conversation' => 'ostatus:conversation',
|
2017-09-18 20:05:48 -07:00
|
|
|
'toot' => 'http://joinmastodon.org/ns#',
|
|
|
|
'Emoji' => 'toot:Emoji',
|
2018-02-21 15:35:46 -08:00
|
|
|
'focalPoint' => { '@container' => '@list', '@id' => 'toot:focalPoint' },
|
2018-03-04 00:19:11 -08:00
|
|
|
'featured' => 'toot:featured',
|
2017-09-02 05:01:23 -07:00
|
|
|
},
|
|
|
|
],
|
|
|
|
}.freeze
|
|
|
|
|
2017-07-14 18:01:39 -07:00
|
|
|
def self.default_key_transform
|
|
|
|
:camel_lower
|
|
|
|
end
|
|
|
|
|
2017-08-12 08:41:03 -07:00
|
|
|
def self.transform_key_casing!(value, _options)
|
|
|
|
ActivityPub::CaseTransform.camel_lower(value)
|
|
|
|
end
|
|
|
|
|
2017-07-14 18:01:39 -07:00
|
|
|
def serializable_hash(options = nil)
|
|
|
|
options = serialization_options(options)
|
2017-09-11 15:16:18 -07:00
|
|
|
serialized_hash = ActiveModelSerializers::Adapter::Attributes.new(serializer, instance_options).serializable_hash(options)
|
|
|
|
CONTEXT.merge(self.class.transform_key_casing!(serialized_hash, instance_options))
|
2017-07-14 18:01:39 -07:00
|
|
|
end
|
|
|
|
end
|