Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master
This commit is contained in:
@@ -4,7 +4,7 @@ class ActivityPub::ActorSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :id, :type, :following, :followers,
|
||||
:inbox, :outbox,
|
||||
:inbox, :outbox, :featured,
|
||||
:preferred_username, :name, :summary,
|
||||
:url, :manually_approves_followers
|
||||
|
||||
@@ -53,6 +53,10 @@ class ActivityPub::ActorSerializer < ActiveModel::Serializer
|
||||
account_outbox_url(object)
|
||||
end
|
||||
|
||||
def featured
|
||||
account_collection_url(object, :featured)
|
||||
end
|
||||
|
||||
def endpoints
|
||||
object
|
||||
end
|
||||
|
||||
24
app/serializers/activitypub/add_serializer.rb
Normal file
24
app/serializers/activitypub/add_serializer.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::AddSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :type, :actor, :target
|
||||
attribute :proper_object, key: :object
|
||||
|
||||
def type
|
||||
'Add'
|
||||
end
|
||||
|
||||
def actor
|
||||
ActivityPub::TagManager.instance.uri_for(object.account)
|
||||
end
|
||||
|
||||
def proper_object
|
||||
ActivityPub::TagManager.instance.uri_for(object)
|
||||
end
|
||||
|
||||
def target
|
||||
account_collection_url(object.account, :featured)
|
||||
end
|
||||
end
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
class ActivityPub::CollectionSerializer < ActiveModel::Serializer
|
||||
def self.serializer_for(model, options)
|
||||
return ActivityPub::ActivitySerializer if model.class.name == 'Status'
|
||||
return ActivityPub::NoteSerializer if model.class.name == 'Status'
|
||||
return ActivityPub::CollectionSerializer if model.class.name == 'ActivityPub::CollectionPresenter'
|
||||
super
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
8
app/serializers/activitypub/outbox_serializer.rb
Normal file
8
app/serializers/activitypub/outbox_serializer.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::OutboxSerializer < ActivityPub::CollectionSerializer
|
||||
def self.serializer_for(model, options)
|
||||
return ActivityPub::ActivitySerializer if model.is_a?(Status)
|
||||
super
|
||||
end
|
||||
end
|
||||
24
app/serializers/activitypub/remove_serializer.rb
Normal file
24
app/serializers/activitypub/remove_serializer.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::RemoveSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :type, :actor, :target
|
||||
attribute :proper_object, key: :object
|
||||
|
||||
def type
|
||||
'Remove'
|
||||
end
|
||||
|
||||
def actor
|
||||
ActivityPub::TagManager.instance.uri_for(object.account)
|
||||
end
|
||||
|
||||
def proper_object
|
||||
ActivityPub::TagManager.instance.uri_for(object)
|
||||
end
|
||||
|
||||
def target
|
||||
account_collection_url(object.account, :featured)
|
||||
end
|
||||
end
|
||||
@@ -52,7 +52,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def languages
|
||||
[ENV.fetch('DEFAULT_LOCALE', I18n.default_locale)]
|
||||
[I18n.default_locale]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user