Skip to content

Commit

Permalink
Add outbox attribute to instance actor (mastodon#14721)
Browse files Browse the repository at this point in the history
It's not useful for now, but it's required by ActivityPub
  • Loading branch information
ClearlyClaire authored and thenameisnigel-old committed Sep 6, 2020
1 parent a1f75c8 commit f8d06d0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
20 changes: 16 additions & 4 deletions app/controllers/activitypub/outboxes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def show
def outbox_presenter
if page_requested?
ActivityPub::CollectionPresenter.new(
id: account_outbox_url(@account, page_params),
id: outbox_url(page_params),
type: :ordered,
part_of: account_outbox_url(@account),
part_of: outbox_url,
prev: prev_page,
next: next_page,
items: @statuses
Expand All @@ -32,12 +32,20 @@ def outbox_presenter
id: account_outbox_url(@account),
type: :ordered,
size: @account.statuses_count,
first: account_outbox_url(@account, page: true),
last: account_outbox_url(@account, page: true, min_id: 0)
first: outbox_url(page: true),
last: outbox_url(page: true, min_id: 0)
)
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
account_outbox_url(@account, page: true, max_id: @statuses.last.id) if @statuses.size == LIMIT
end
Expand Down Expand Up @@ -65,4 +73,8 @@ def page_requested?
def page_params
{ page: true, max_id: params[:max_id], min_id: params[:min_id] }.compact
end

def set_account
@account = params[:account_username].present? ? Account.find_local!(username_param) : Account.representative
end
end
2 changes: 1 addition & 1 deletion app/controllers/instance_actors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ def set_account
end

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
2 changes: 1 addition & 1 deletion app/serializers/activitypub/actor_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def devices
end

def outbox
account_outbox_url(object)
object.instance_actor? ? instance_actor_outbox_url : account_outbox_url(object)
end

def featured
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

resource :instance_actor, path: 'actor', only: [:show] do
resource :inbox, only: [:create], module: :activitypub
resource :outbox, only: [:show], module: :activitypub
end

devise_scope :user do
Expand Down

0 comments on commit f8d06d0

Please sign in to comment.