2020-11-25 21:22:37 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-12-03 04:22:51 +00:00
|
|
|
class Api::V1::ChatConversationAccountsController < Api::BaseController
|
|
|
|
before_action -> { authorize_if_got_token! :read, :'read:chats' }, except: [:create, :follow, :unfollow, :block, :unblock, :mute, :unmute]
|
|
|
|
before_action -> { doorkeeper_authorize! :write, :'write:chats' }, only: [:create]
|
|
|
|
|
|
|
|
before_action :require_user!
|
2020-11-25 21:22:37 +00:00
|
|
|
before_action :set_account, except: [:create]
|
|
|
|
|
|
|
|
def show
|
|
|
|
#
|
|
|
|
end
|
|
|
|
|
|
|
|
def block
|
|
|
|
BlockMessengerService.new.call(current_user.account, @account)
|
|
|
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
|
|
|
end
|
|
|
|
|
|
|
|
def mute
|
|
|
|
MuteMessengerService.new.call(current_user.account, @account, notifications: truthy_param?(:notifications))
|
|
|
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
|
|
|
end
|
|
|
|
|
|
|
|
def unblock
|
|
|
|
UnblockMessengerService.new.call(current_user.account, @account)
|
|
|
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
|
|
|
end
|
|
|
|
|
|
|
|
def unmute
|
|
|
|
UnmuteMessegerService.new.call(current_user.account, @account)
|
|
|
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_account
|
2020-12-03 04:22:51 +00:00
|
|
|
# @account = Account.find(params[:id])
|
2020-11-25 21:22:37 +00:00
|
|
|
end
|
|
|
|
|
2020-12-03 04:22:51 +00:00
|
|
|
# def relationships(**options)
|
|
|
|
# AccountRelationshipsPresenter.new([@account.id], current_user.account_id, options)
|
|
|
|
# end
|
2020-11-25 21:22:37 +00:00
|
|
|
|
|
|
|
def check_account_suspension
|
|
|
|
gone if @account.suspended?
|
|
|
|
end
|
|
|
|
|
2020-12-03 04:22:51 +00:00
|
|
|
# def account_params
|
|
|
|
# params.permit(:username, :email, :password, :agreement, :locale)
|
|
|
|
# end
|
|
|
|
|
2020-11-25 21:22:37 +00:00
|
|
|
end
|