about summary refs log tree commit diff
path: root/app/serializers/activitypub
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers/activitypub')
-rw-r--r--app/serializers/activitypub/note_serializer.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb
index 24c39f3c9..d0e6290c1 100644
--- a/app/serializers/activitypub/note_serializer.rb
+++ b/app/serializers/activitypub/note_serializer.rb
@@ -90,6 +90,7 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
     include RoutingHelper
 
     attributes :type, :media_type, :url, :name
+    attribute :focal_point, if: :focal_point?
 
     def type
       'Document'
@@ -106,6 +107,14 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
     def url
       object.local? ? full_asset_url(object.file.url(:original, false)) : object.remote_url
     end
+
+    def focal_point?
+      object.file.meta.is_a?(Hash) && object.file.meta['focus'].is_a?(Hash)
+    end
+
+    def focal_point
+      [object.file.meta['focus']['x'], object.file.meta['focus']['y']]
+    end
   end
 
   class MentionSerializer < ActiveModel::Serializer