mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-29 14:53:41 +01:00
serialize custom emoji reactions properly for AP
Akkoma and possibly others expect the `tag` field in an EmojiReact activity to be an array, not just a single object, so it's being wrapped into one now. I'm not entirely sure whether this is the idiomatic way of doing it tbh, but it works fine.
This commit is contained in:
parent
a556d81cde
commit
14d1f7d9b3
1 changed files with 7 additions and 2 deletions
|
@ -3,8 +3,7 @@
|
||||||
class ActivityPub::EmojiReactionSerializer < ActivityPub::Serializer
|
class ActivityPub::EmojiReactionSerializer < ActivityPub::Serializer
|
||||||
attributes :id, :type, :actor, :content
|
attributes :id, :type, :actor, :content
|
||||||
attribute :virtual_object, key: :object
|
attribute :virtual_object, key: :object
|
||||||
|
attribute :custom_emoji, key: :tag, unless: -> { object.custom_emoji.nil? }
|
||||||
has_one :custom_emoji, key: :tag, serializer: ActivityPub::EmojiSerializer, unless: -> { object.custom_emoji.nil? }
|
|
||||||
|
|
||||||
def id
|
def id
|
||||||
[ActivityPub::TagManager.instance.uri_for(object.account), '#emoji_reactions/', object.id].join
|
[ActivityPub::TagManager.instance.uri_for(object.account), '#emoji_reactions/', object.id].join
|
||||||
|
@ -31,4 +30,10 @@ class ActivityPub::EmojiReactionSerializer < ActivityPub::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
alias reaction content
|
alias reaction content
|
||||||
|
|
||||||
|
# Akkoma (and possibly others) expect `tag` to be an array, so we can't just
|
||||||
|
# use the has_one shorthand because we need to wrap it into an array manually
|
||||||
|
def custom_emoji
|
||||||
|
[ActivityPub::EmojiSerializer.new(object.custom_emoji).serializable_hash]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue