Add outbox attribute to instance actor (#14721)
It's not useful for now, but it's required by ActivityPub
This commit is contained in:
parent
33ad850c98
commit
abee40b232
|
@ -20,9 +20,9 @@ class ActivityPub::OutboxesController < ActivityPub::BaseController
|
||||||
def outbox_presenter
|
def outbox_presenter
|
||||||
if page_requested?
|
if page_requested?
|
||||||
ActivityPub::CollectionPresenter.new(
|
ActivityPub::CollectionPresenter.new(
|
||||||
id: account_outbox_url(@account, page_params),
|
id: outbox_url(page_params),
|
||||||
type: :ordered,
|
type: :ordered,
|
||||||
part_of: account_outbox_url(@account),
|
part_of: outbox_url,
|
||||||
prev: prev_page,
|
prev: prev_page,
|
||||||
next: next_page,
|
next: next_page,
|
||||||
items: @statuses
|
items: @statuses
|
||||||
|
@ -32,12 +32,20 @@ class ActivityPub::OutboxesController < ActivityPub::BaseController
|
||||||
id: account_outbox_url(@account),
|
id: account_outbox_url(@account),
|
||||||
type: :ordered,
|
type: :ordered,
|
||||||
size: @account.statuses_count,
|
size: @account.statuses_count,
|
||||||
first: account_outbox_url(@account, page: true),
|
first: outbox_url(page: true),
|
||||||
last: account_outbox_url(@account, page: true, min_id: 0)
|
last: outbox_url(page: true, min_id: 0)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def outbox_url(**kwargs)
|
||||||
|
if params[:account_username].present?
|
||||||
|
account_outbox_url(@account, **kwargs)
|
||||||
|
else
|
||||||
|
instance_actor_outbox_url(**kwargs)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def next_page
|
def next_page
|
||||||
account_outbox_url(@account, page: true, max_id: @statuses.last.id) if @statuses.size == LIMIT
|
account_outbox_url(@account, page: true, max_id: @statuses.last.id) if @statuses.size == LIMIT
|
||||||
end
|
end
|
||||||
|
@ -65,4 +73,8 @@ class ActivityPub::OutboxesController < ActivityPub::BaseController
|
||||||
def page_params
|
def page_params
|
||||||
{ page: true, max_id: params[:max_id], min_id: params[:min_id] }.compact
|
{ page: true, max_id: params[:max_id], min_id: params[:min_id] }.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_account
|
||||||
|
@account = params[:account_username].present? ? Account.find_local!(username_param) : Account.representative
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,6 +17,6 @@ class InstanceActorsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def restrict_fields_to
|
def restrict_fields_to
|
||||||
%i(id type preferred_username inbox public_key endpoints url manually_approves_followers)
|
%i(id type preferred_username inbox outbox public_key endpoints url manually_approves_followers)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,7 +74,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def outbox
|
def outbox
|
||||||
account_outbox_url(object)
|
object.instance_actor? ? instance_actor_outbox_url : account_outbox_url(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
def featured
|
def featured
|
||||||
|
|
|
@ -37,6 +37,7 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resource :instance_actor, path: 'actor', only: [:show] do
|
resource :instance_actor, path: 'actor', only: [:show] do
|
||||||
resource :inbox, only: [:create], module: :activitypub
|
resource :inbox, only: [:create], module: :activitypub
|
||||||
|
resource :outbox, only: [:show], module: :activitypub
|
||||||
end
|
end
|
||||||
|
|
||||||
devise_scope :user do
|
devise_scope :user do
|
||||||
|
|
Loading…
Reference in New Issue