From 44829d8216001e3d8183dbd12cacc5a2f4826751 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 4 Mar 2018 07:21:41 +0100 Subject: Fix missing focalPoint in ActivityPub JSON (#6609) --- app/serializers/activitypub/note_serializer.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/serializers/activitypub/note_serializer.rb') 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 -- cgit