0
0
Fork 0

Define missing JSON-LD properties (#4767)

Using _: property names is discouraged, as in the future,
canonicalization may throw an error when encountering that instead
of discarding it silently like it does now.

We are defining some ActivityStreams properties which we expect
to land in ActivityStreams eventually, to ensure that future versions
of Mastodon will remain compatible with this even once that happens.
Those would be `locked`, `sensitive` and `Hashtag`

We are defining a custom context inline for some properties which we
do not expect to land in any other context. `atomUri`, `inReplyToAtomUri`
and `conversation` are part of the custom defined OStatus context.
This commit is contained in:
Eugen Rochko 2017-09-02 14:01:23 +02:00 committed by GitHub
parent 1b1e025b41
commit 1b5806b744
8 changed files with 41 additions and 17 deletions

View file

@ -3,14 +3,13 @@
class ActivityPub::NoteSerializer < ActiveModel::Serializer
attributes :id, :type, :summary, :content,
:in_reply_to, :published, :url,
:attributed_to, :to, :cc, :sensitive
:attributed_to, :to, :cc, :sensitive,
:atom_uri, :in_reply_to_atom_uri,
:conversation
has_many :media_attachments, key: :attachment
has_many :virtual_tags, key: :tag
attribute :atom_uri, key: '_:atomUri', if: :local?
attribute :in_reply_to_atom_uri, key: '_:inReplyToAtomUri'
def id
ActivityPub::TagManager.instance.uri_for(object)
end
@ -62,6 +61,8 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
end
def atom_uri
return unless object.local?
::TagManager.instance.uri_for(object)
end
@ -71,6 +72,14 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
::TagManager.instance.uri_for(object.thread)
end
def conversation
if object.conversation.uri?
object.conversation.uri
else
TagManager.instance.unique_tag(object.conversation.created_at, object.conversation.id, 'Conversation')
end
end
def local?
object.account.local?
end