about summary refs log tree commit diff
path: root/app/serializers
diff options
context:
space:
mode:
authordogelover911 <84288771+dogelover911@users.noreply.github.com>2021-05-16 16:09:03 -0500
committerGitHub <noreply@github.com>2021-05-16 23:09:03 +0200
commit52c4e17f7e17d44f1ccdd268f6b8d88f812ff750 (patch)
treed353394632d7088ffc36d1be85d01847dc11ba71 /app/serializers
parentf09322f9cca9e05093af4ae4051d27b8c9244a0f (diff)
Add width and height to attachments in ActivityPub (#16245)
Co-authored-by: dogelover911 <dogelover911@localhost>
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/activitypub/note_serializer.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb
index 6f9e1ca63..7c52b634d 100644
--- a/app/serializers/activitypub/note_serializer.rb
+++ b/app/serializers/activitypub/note_serializer.rb
@@ -170,6 +170,8 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
 
     attributes :type, :media_type, :url, :name, :blurhash
     attribute :focal_point, if: :focal_point?
+    attribute :width, if: :width?
+    attribute :height, if: :height?
 
     has_one :icon, serializer: ActivityPub::ImageSerializer, if: :thumbnail?
 
@@ -204,6 +206,22 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
     def thumbnail?
       object.thumbnail.present?
     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
 
   class MentionSerializer < ActivityPub::Serializer