Minor ActivityPub JSON fixes (#4214)

- Objects must have attributedTo instead of actor
- The current attribute belongs to CollectionPage, not Collection
This commit is contained in:
Eugen Rochko 2017-07-16 10:28:55 +02:00 committed by GitHub
parent 35b868eeca
commit a6328fc1b1
7 changed files with 4 additions and 9 deletions

View file

@ -20,7 +20,6 @@ class ActivityPub::OutboxesController < Api::BaseController
ActivityPub::CollectionPresenter.new( ActivityPub::CollectionPresenter.new(
id: account_outbox_url(@account), id: account_outbox_url(@account),
type: :ordered, type: :ordered,
current: account_outbox_url(@account),
size: @account.statuses_count, size: @account.statuses_count,
items: @statuses items: @statuses
) )

View file

@ -21,7 +21,6 @@ class FollowerAccountsController < ApplicationController
ActivityPub::CollectionPresenter.new( ActivityPub::CollectionPresenter.new(
id: account_followers_url(@account), id: account_followers_url(@account),
type: :ordered, type: :ordered,
current: account_followers_url(@account),
size: @account.followers_count, size: @account.followers_count,
items: @follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.account) } items: @follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.account) }
) )

View file

@ -21,7 +21,6 @@ class FollowingAccountsController < ApplicationController
ActivityPub::CollectionPresenter.new( ActivityPub::CollectionPresenter.new(
id: account_following_index_url(@account), id: account_following_index_url(@account),
type: :ordered, type: :ordered,
current: account_following_index_url(@account),
size: @account.following_count, size: @account.following_count,
items: @follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.target_account) } items: @follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.target_account) }
) )

View file

@ -23,7 +23,6 @@ class TagsController < ApplicationController
ActivityPub::CollectionPresenter.new( ActivityPub::CollectionPresenter.new(
id: tag_url(@tag), id: tag_url(@tag),
type: :ordered, type: :ordered,
current: tag_url(@tag),
size: @tag.statuses.count, size: @tag.statuses.count,
items: @statuses.map { |s| ActivityPub::TagManager.instance.uri_for(s) } items: @statuses.map { |s| ActivityPub::TagManager.instance.uri_for(s) }
) )

View file

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
class ActivityPub::CollectionPresenter < ActiveModelSerializers::Model class ActivityPub::CollectionPresenter < ActiveModelSerializers::Model
attributes :id, :type, :current, :size, :items attributes :id, :type, :size, :items
end end

View file

@ -6,8 +6,7 @@ class ActivityPub::CollectionSerializer < ActiveModel::Serializer
super super
end end
attributes :id, :type, :total_items, attributes :id, :type, :total_items
:current
has_many :items, key: :ordered_items has_many :items, key: :ordered_items

View file

@ -3,7 +3,7 @@
class ActivityPub::NoteSerializer < ActiveModel::Serializer class ActivityPub::NoteSerializer < ActiveModel::Serializer
attributes :id, :type, :summary, :content, attributes :id, :type, :summary, :content,
:in_reply_to, :published, :url, :in_reply_to, :published, :url,
:actor, :to, :cc, :sensitive :attributed_to, :to, :cc, :sensitive
has_many :media_attachments, key: :attachment has_many :media_attachments, key: :attachment
has_many :virtual_tags, key: :tag has_many :virtual_tags, key: :tag
@ -36,7 +36,7 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
ActivityPub::TagManager.instance.url_for(object) ActivityPub::TagManager.instance.url_for(object)
end end
def actor def attributed_to
ActivityPub::TagManager.instance.uri_for(object.account) ActivityPub::TagManager.instance.uri_for(object.account)
end end