mastodon/app/serializers/activitypub/delete_serializer.rb
Eugen Rochko 1b5806b744 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.
2017-09-02 14:01:23 +02:00

36 lines
662 B
Ruby

# frozen_string_literal: true
class ActivityPub::DeleteSerializer < ActiveModel::Serializer
class TombstoneSerializer < ActiveModel::Serializer
attributes :id, :type, :atom_uri
def id
ActivityPub::TagManager.instance.uri_for(object)
end
def type
'Tombstone'
end
def atom_uri
::TagManager.instance.uri_for(object)
end
end
attributes :id, :type, :actor
has_one :object, serializer: TombstoneSerializer
def id
[ActivityPub::TagManager.instance.uri_for(object), '#delete'].join
end
def type
'Delete'
end
def actor
ActivityPub::TagManager.instance.uri_for(object.account)
end
end