mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-25 17:51:36 +01:00
6da2a0d0fb
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.
39 lines
987 B
Ruby
39 lines
987 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ActivityPub::EmojiReactionSerializer < ActivityPub::Serializer
|
|
attributes :id, :type, :actor, :content
|
|
attribute :virtual_object, key: :object
|
|
attribute :custom_emoji, key: :tag, unless: -> { object.custom_emoji.nil? }
|
|
|
|
def id
|
|
[ActivityPub::TagManager.instance.uri_for(object.account), '#emoji_reactions/', object.id].join
|
|
end
|
|
|
|
def type
|
|
'EmojiReact'
|
|
end
|
|
|
|
def actor
|
|
ActivityPub::TagManager.instance.uri_for(object.account)
|
|
end
|
|
|
|
def virtual_object
|
|
ActivityPub::TagManager.instance.uri_for(object.status)
|
|
end
|
|
|
|
def content
|
|
if object.custom_emoji.nil?
|
|
object.name
|
|
else
|
|
":#{object.name}:"
|
|
end
|
|
end
|
|
|
|
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
|