Fix avatar and profile header descriptions not being serialized over ActivityPub (#39352)
This commit is contained in:
1 parent
b48f907b20
commit
e697d44144
3 files changed
+31
-2
No files matched your search
@@ -44,6 +44,16 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
||||
end
|
||||
end
|
||||
|
||||
class ImageWithDescription < SimpleDelegator
|
||||
attr_reader :description
|
||||
|
||||
def initialize(object, description)
|
||||
super(object)
|
||||
|
||||
@description = description
|
||||
end
|
||||
end
|
||||
|
||||
has_one :endpoints, serializer: EndpointsSerializer
|
||||
|
||||
has_one :icon, serializer: ActivityPub::ImageSerializer, if: :avatar_exists?
|
||||
@@ -120,11 +130,11 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
||||
end
|
||||
|
||||
def icon
|
||||
object.avatar
|
||||
ImageWithDescription.new(object.avatar, object.avatar_description)
|
||||
end
|
||||
|
||||
def image
|
||||
object.header
|
||||
ImageWithDescription.new(object.header, object.header_description)
|
||||
end
|
||||
|
||||
def public_key
|
||||
|
||||
@@ -7,6 +7,7 @@ class ActivityPub::ImageSerializer < ActivityPub::Serializer
|
||||
|
||||
attributes :type, :media_type, :url
|
||||
attribute :focal_point, if: :focal_point?
|
||||
attribute :summary, if: :summary?
|
||||
|
||||
def type
|
||||
'Image'
|
||||
@@ -27,4 +28,12 @@ class ActivityPub::ImageSerializer < ActivityPub::Serializer
|
||||
def focal_point
|
||||
[object.meta['focus']['x'], object.meta['focus']['y']]
|
||||
end
|
||||
|
||||
def summary?
|
||||
object.respond_to?(:description) && object.description.present?
|
||||
end
|
||||
|
||||
def summary
|
||||
object.description
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user