|
|
@ -8,49 +8,38 @@ class Api::V1::AccountsController < Api::BaseController |
|
|
|
|
|
|
|
respond_to :json |
|
|
|
|
|
|
|
def show; end |
|
|
|
def show |
|
|
|
render json: @account, serializer: REST::AccountSerializer |
|
|
|
end |
|
|
|
|
|
|
|
def follow |
|
|
|
FollowService.new.call(current_user.account, @account.acct) |
|
|
|
set_relationship |
|
|
|
render :relationship |
|
|
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships |
|
|
|
end |
|
|
|
|
|
|
|
def block |
|
|
|
BlockService.new.call(current_user.account, @account) |
|
|
|
|
|
|
|
@following = { @account.id => false } |
|
|
|
@followed_by = { @account.id => false } |
|
|
|
@blocking = { @account.id => true } |
|
|
|
@requested = { @account.id => false } |
|
|
|
@muting = { @account.id => current_account.muting?(@account.id) } |
|
|
|
@domain_blocking = { @account.id => current_account.domain_blocking?(@account.domain) } |
|
|
|
|
|
|
|
render :relationship |
|
|
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships |
|
|
|
end |
|
|
|
|
|
|
|
def mute |
|
|
|
MuteService.new.call(current_user.account, @account) |
|
|
|
set_relationship |
|
|
|
render :relationship |
|
|
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships |
|
|
|
end |
|
|
|
|
|
|
|
def unfollow |
|
|
|
UnfollowService.new.call(current_user.account, @account) |
|
|
|
set_relationship |
|
|
|
render :relationship |
|
|
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships |
|
|
|
end |
|
|
|
|
|
|
|
def unblock |
|
|
|
UnblockService.new.call(current_user.account, @account) |
|
|
|
set_relationship |
|
|
|
render :relationship |
|
|
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships |
|
|
|
end |
|
|
|
|
|
|
|
def unmute |
|
|
|
UnmuteService.new.call(current_user.account, @account) |
|
|
|
set_relationship |
|
|
|
render :relationship |
|
|
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships |
|
|
|
end |
|
|
|
|
|
|
|
private |
|
|
@ -59,12 +48,7 @@ class Api::V1::AccountsController < Api::BaseController |
|
|
|
@account = Account.find(params[:id]) |
|
|
|
end |
|
|
|
|
|
|
|
def set_relationship |
|
|
|
@following = Account.following_map([@account.id], current_user.account_id) |
|
|
|
@followed_by = Account.followed_by_map([@account.id], current_user.account_id) |
|
|
|
@blocking = Account.blocking_map([@account.id], current_user.account_id) |
|
|
|
@muting = Account.muting_map([@account.id], current_user.account_id) |
|
|
|
@requested = Account.requested_map([@account.id], current_user.account_id) |
|
|
|
@domain_blocking = Account.domain_blocking_map([@account.id], current_user.account_id) |
|
|
|
def relationships |
|
|
|
AccountRelationshipsPresenter.new([@account.id], current_user.account_id) |
|
|
|
end |
|
|
|
end |