gab-social/app/controllers/api/v1/chat_conversation_accounts_controller.rb

53 lines
1.6 KiB
Ruby
Raw Normal View History

2020-11-25 21:22:37 +00:00
# frozen_string_literal: true
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
# @account = Account.find(params[:id])
2020-11-25 21:22:37 +00:00
end
# 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
# def account_params
# params.permit(:username, :email, :password, :agreement, :locale)
# end
2020-11-25 21:22:37 +00:00
end