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

62 lines
1.7 KiB
Ruby
Raw Normal View History

2020-11-25 21:22:37 +00:00
# frozen_string_literal: true
class Api::V1::ChatConversationAccountsController < Api::BaseController
2020-12-10 16:51:45 +00:00
before_action -> { authorize_if_got_token! :read, :'read:chats' }
before_action -> { doorkeeper_authorize! :write, :'write:chats' }
before_action :require_user!
2020-12-10 16:51:45 +00:00
before_action :set_account
2020-11-25 21:22:37 +00:00
2020-12-10 16:51:45 +00:00
def is_messenger_blocked
2020-11-25 21:22:37 +00:00
#
end
2020-12-10 16:51:45 +00:00
def is_messenger_muted
#
end
def block_messenger
2020-11-25 21:22:37 +00:00
BlockMessengerService.new.call(current_user.account, @account)
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
end
2020-12-10 16:51:45 +00:00
def mute_messenger
MuteMessengerService.new.call(current_user.account, @account)
2020-11-25 21:22:37 +00:00
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
end
2020-12-10 16:51:45 +00:00
def unblock_messenger
2020-11-25 21:22:37 +00:00
UnblockMessengerService.new.call(current_user.account, @account)
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
end
2020-12-10 16:51:45 +00:00
def unmute_messenger
2020-11-25 21:22:37 +00:00
UnmuteMessegerService.new.call(current_user.account, @account)
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
end
2020-12-16 00:31:30 +00:00
def set_expiration_policy
if current_user.account.is_pro
#
render json: @chat_conversation_account, serializer: REST::ChatConversationAccountSerializer
else
render json: { error: 'You need to be a GabPRO member to access this' }, status: 422
end
end
2020-11-25 21:22:37 +00:00
private
def set_account
2020-12-10 16:51:45 +00:00
@account = Account.find(params[:id])
2020-11-25 21:22:37 +00:00
end
def check_account_suspension
gone if @account.suspended?
end
2020-12-10 16:51:45 +00:00
def relationships(**options)
AccountRelationshipsPresenter.new([@account.id], current_user.account_id, options)
end
2020-11-25 21:22:37 +00:00
end