mirror of https://github.com/mastodon/mastodon
Add ActivityPub serializer for Undo of Announce (#4703)
This commit is contained in:
parent
8ecfdd8795
commit
2a2698e450
|
@ -0,0 +1,19 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class ActivityPub::UndoAnnounceSerializer < ActiveModel::Serializer
|
||||||
|
attributes :id, :type, :actor
|
||||||
|
|
||||||
|
has_one :object, serializer: ActivityPub::ActivitySerializer
|
||||||
|
|
||||||
|
def id
|
||||||
|
[ActivityPub::TagManager.instance.uri_for(object.account), '#announces/', object.id, '/undo'].join
|
||||||
|
end
|
||||||
|
|
||||||
|
def type
|
||||||
|
'Undo'
|
||||||
|
end
|
||||||
|
|
||||||
|
def actor
|
||||||
|
ActivityPub::TagManager.instance.uri_for(object.account)
|
||||||
|
end
|
||||||
|
end
|
|
@ -140,7 +140,7 @@ class BatchedRemoveStatusService < BaseService
|
||||||
|
|
||||||
@activity_json[status.id] = sign_json(status, ActiveModelSerializers::SerializableResource.new(
|
@activity_json[status.id] = sign_json(status, ActiveModelSerializers::SerializableResource.new(
|
||||||
status,
|
status,
|
||||||
serializer: ActivityPub::DeleteSerializer,
|
serializer: status.reblog? ? ActivityPub::UndoAnnounceSerializer : ActivityPub::DeleteSerializer,
|
||||||
adapter: ActivityPub::Adapter
|
adapter: ActivityPub::Adapter
|
||||||
).as_json)
|
).as_json)
|
||||||
end
|
end
|
||||||
|
|
|
@ -81,7 +81,7 @@ class RemoveStatusService < BaseService
|
||||||
def activity_json
|
def activity_json
|
||||||
@activity_json ||= ActiveModelSerializers::SerializableResource.new(
|
@activity_json ||= ActiveModelSerializers::SerializableResource.new(
|
||||||
@status,
|
@status,
|
||||||
serializer: ActivityPub::DeleteSerializer,
|
serializer: @status.reblog? ? ActivityPub::UndoAnnounceSerializer : ActivityPub::DeleteSerializer,
|
||||||
adapter: ActivityPub::Adapter
|
adapter: ActivityPub::Adapter
|
||||||
).as_json
|
).as_json
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue