1 # frozen_string_literal: true
3 class Api
::V1::AccountsController < Api
::BaseController
4 before_action
-> { doorkeeper_authorize!
:read }, except
: [:follow, :unfollow, :block, :unblock, :mute, :unmute]
5 before_action
-> { doorkeeper_authorize!
:follow }, only
: [:follow, :unfollow, :block, :unblock, :mute, :unmute]
6 before_action
:require_user!
, except
: [:show]
7 before_action
:set_account
12 render json
: @account, serializer
: REST
::AccountSerializer
16 FollowService
.new
.call(current_user
.account
, @account.acct
, reblogs
: params
[:reblogs])
18 options
= @account.locked
? ? {} : { following_map
: { @account.id
=> { reblogs
: params
[:reblogs] } }, requested_map
: { @account.id
=> false } }
20 render json
: @account, serializer
: REST
::RelationshipSerializer, relationships
: relationships(options
)
24 BlockService
.new
.call(current_user
.account
, @account)
25 render json
: @account, serializer
: REST
::RelationshipSerializer, relationships
: relationships
29 MuteService
.new
.call(current_user
.account
, @account, notifications
: params
[:notifications])
30 render json
: @account, serializer
: REST
::RelationshipSerializer, relationships
: relationships
34 UnfollowService
.new
.call(current_user
.account
, @account)
35 render json
: @account, serializer
: REST
::RelationshipSerializer, relationships
: relationships
39 UnblockService
.new
.call(current_user
.account
, @account)
40 render json
: @account, serializer
: REST
::RelationshipSerializer, relationships
: relationships
44 UnmuteService
.new
.call(current_user
.account
, @account)
45 render json
: @account, serializer
: REST
::RelationshipSerializer, relationships
: relationships
51 @account = Account
.find(params
[:id])
54 def relationships(**options
)
55 AccountRelationshipsPresenter
.new([@account.id
], current_user
.account_id
, options
)