Add width and height to attachments in ActivityPub (#16245)
Co-authored-by: dogelover911 <dogelover911@localhost>
This commit is contained in:
parent
f09322f9cc
commit
52c4e17f7e
|
@ -170,6 +170,8 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
||||||
|
|
||||||
attributes :type, :media_type, :url, :name, :blurhash
|
attributes :type, :media_type, :url, :name, :blurhash
|
||||||
attribute :focal_point, if: :focal_point?
|
attribute :focal_point, if: :focal_point?
|
||||||
|
attribute :width, if: :width?
|
||||||
|
attribute :height, if: :height?
|
||||||
|
|
||||||
has_one :icon, serializer: ActivityPub::ImageSerializer, if: :thumbnail?
|
has_one :icon, serializer: ActivityPub::ImageSerializer, if: :thumbnail?
|
||||||
|
|
||||||
|
@ -204,6 +206,22 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
||||||
def thumbnail?
|
def thumbnail?
|
||||||
object.thumbnail.present?
|
object.thumbnail.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def width?
|
||||||
|
object.file.meta&.dig('original', 'width').present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def height?
|
||||||
|
object.file.meta&.dig('original', 'height').present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def width
|
||||||
|
object.file.meta.dig('original', 'width')
|
||||||
|
end
|
||||||
|
|
||||||
|
def height
|
||||||
|
object.file.meta.dig('original', 'height')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class MentionSerializer < ActivityPub::Serializer
|
class MentionSerializer < ActivityPub::Serializer
|
||||||
|
|
Loading…
Reference in a new issue