about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-03-04 07:21:41 +0100
committerGitHub <noreply@github.com>2018-03-04 07:21:41 +0100
commit44829d8216001e3d8183dbd12cacc5a2f4826751 (patch)
treedd6e39363fb82e9c1fe686cb4e870a10efe43fc0 /app
parent49092945ab86725180e202945ae1bec03a32a634 (diff)
Fix missing focalPoint in ActivityPub JSON (#6609)
Diffstat (limited to 'app')
-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