diff options
author | imncls <himasoto@gmail.com> | 2018-02-23 23:28:31 +0900 |
---|---|---|
committer | imncls <himasoto@gmail.com> | 2018-02-23 23:28:31 +0900 |
commit | bb6988a7ac319c08776d8c07204232a67f992671 (patch) | |
tree | 4a53349374bc4a871a6ce74b786a8e747803155c /app/serializers | |
parent | 544543e40a723d9719f5571bd4c3455a6a69fccd (diff) | |
parent | e668180044560e28bdc5eef94744c210013efcda (diff) |
Merge branch 'master' of https://github.com/tootsuite/mastodon
# Conflicts: # app/controllers/settings/exports_controller.rb # app/models/media_attachment.rb # app/models/status.rb # app/views/about/show.html.haml # docker_entrypoint.sh # spec/views/about/show.html.haml_spec.rb
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/activitypub/collection_serializer.rb | 4 | ||||
-rw-r--r-- | app/serializers/activitypub/image_serializer.rb | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/app/serializers/activitypub/collection_serializer.rb b/app/serializers/activitypub/collection_serializer.rb index 9832133fc..d43af3f8e 100644 --- a/app/serializers/activitypub/collection_serializer.rb +++ b/app/serializers/activitypub/collection_serializer.rb @@ -13,8 +13,8 @@ class ActivityPub::CollectionSerializer < ActiveModel::Serializer attribute :part_of, if: -> { object.part_of.present? } has_one :first, if: -> { object.first.present? } - has_many :items, key: :items, if: -> { (object.items.present? || page?) && !ordered? } - has_many :items, key: :ordered_items, if: -> { (object.items.present? || page?) && ordered? } + has_many :items, key: :items, if: -> { (!object.items.nil? || page?) && !ordered? } + has_many :items, key: :ordered_items, if: -> { (!object.items.nil? || page?) && ordered? } def type if page? diff --git a/app/serializers/activitypub/image_serializer.rb b/app/serializers/activitypub/image_serializer.rb index a015c6b1b..3c08f77e8 100644 --- a/app/serializers/activitypub/image_serializer.rb +++ b/app/serializers/activitypub/image_serializer.rb @@ -4,6 +4,7 @@ class ActivityPub::ImageSerializer < ActiveModel::Serializer include RoutingHelper attributes :type, :media_type, :url + attribute :focal_point, if: :focal_point? def type 'Image' @@ -16,4 +17,12 @@ class ActivityPub::ImageSerializer < ActiveModel::Serializer def media_type object.content_type end + + def focal_point? + object.respond_to?(:meta) && object.meta.is_a?(Hash) && object.meta['focus'].is_a?(Hash) + end + + def focal_point + [object.meta['focus']['x'], object.meta['focus']['y']] + end end |