about summary refs log tree commit diff
path: root/app/controllers/activitypub/outboxes_controller.rb
blob: 9f97ff6226d67480861a8672cf54f3d41717787a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

class ActivityPub::OutboxesController < Api::BaseController
  before_action :set_account

  def show
    @statuses = @account.statuses.permitted_for(@account, current_account).paginate_by_max_id(20, params[:max_id], params[:since_id])
    @statuses = cache_collection(@statuses, Status)

    render json: outbox_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
  end

  private

  def set_account
    @account = Account.find_local!(params[:account_username])
  end

  def outbox_presenter
    ActivityPub::CollectionPresenter.new(
      id: account_outbox_url(@account),
      type: :ordered,
      size: @account.statuses_count,
      items: @statuses
    )
  end
end