1 # frozen_string_literal: true
3 class FollowingAccountsController
< ApplicationController
4 include AccountControllerConcern
11 next if @account.user_hides_network
?
14 @relationships = AccountRelationshipsPresenter
.new(follows
.map(&:target_account_id), current_user
.account_id
) if user_signed_in
?
18 raise Mastodon
::NotPermittedError if params
[:page].present
? && @account.user_hides_network
?
20 render json
: collection_presenter
,
21 serializer
: ActivityPub
::CollectionSerializer,
22 adapter
: ActivityPub
::Adapter,
23 content_type
: 'application/activity+json
'
31 @follows ||= Follow.where(account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:target_account)
35 account_following_index_url(@account, page: page) unless page.nil?
38 def collection_presenter
39 if params[:page].present?
40 ActivityPub::CollectionPresenter.new(
41 id: account_following_index_url(@account, page: params.fetch(:page, 1)),
43 size: @account.following_count,
44 items: follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.target_account) },
45 part_of: account_following_index_url(@account),
46 next: page_url(follows.next_page),
47 prev: page_url(follows.prev_page)
50 ActivityPub::CollectionPresenter.new(
51 id: account_following_index_url(@account),
53 size: @account.following_count,