feat: editor controller
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
class Captain::EditorPolicy < ApplicationPolicy
|
||||
def process_event?
|
||||
true
|
||||
end
|
||||
end
|
||||
@@ -69,6 +69,9 @@ Rails.application.routes.draw do
|
||||
end
|
||||
resources :custom_tools
|
||||
resources :documents, only: [:index, :show, :create, :destroy]
|
||||
resource :editor, only: [], controller: 'editor' do
|
||||
post :process_event
|
||||
end
|
||||
end
|
||||
resource :saml_settings, only: [:show, :create, :update, :destroy]
|
||||
resources :agent_bots, only: [:index, :create, :show, :update, :destroy] do
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
class Api::V1::Accounts::Captain::EditorController < Api::V1::Accounts::BaseController
|
||||
before_action :check_authorization
|
||||
|
||||
def process_event
|
||||
result = Captain::EditorService.new(
|
||||
account: Current.account,
|
||||
event: params[:event]
|
||||
).perform
|
||||
|
||||
if result.nil?
|
||||
render json: { message: nil }
|
||||
elsif result[:error]
|
||||
render json: { error: result[:error] }, status: :unprocessable_entity
|
||||
else
|
||||
render json: { message: result[:message] }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_authorization
|
||||
authorize(:'captain/editor')
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user