# Pull Request Template ## Description Relocate controller from enterprise/ to app/ and add Api::V1::Accounts::Captain::TasksController.prepend_mod_with for EE overrides. Fixes: Ai assist giving 404 on CE ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration. before: <img width="482" height="130" alt="image" src="https://github.com/user-attachments/assets/f51dc28a-ac54-45c4-9015-6f956fdf5057" /> after: <img width="458" height="182" alt="image" src="https://github.com/user-attachments/assets/eb86a679-5482-4157-9f4e-f3e9953d8649" /> ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] Any dependent changes have been merged and published in downstream modules Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
74 lines
1.9 KiB
Ruby
74 lines
1.9 KiB
Ruby
class Api::V1::Accounts::Captain::TasksController < Api::V1::Accounts::BaseController
|
|
before_action :check_authorization
|
|
|
|
def rewrite
|
|
result = Captain::RewriteService.new(
|
|
account: Current.account,
|
|
content: params[:content],
|
|
operation: params[:operation],
|
|
conversation_display_id: params[:conversation_display_id]
|
|
).perform
|
|
|
|
render_result(result)
|
|
end
|
|
|
|
def summarize
|
|
result = Captain::SummaryService.new(
|
|
account: Current.account,
|
|
conversation_display_id: params[:conversation_display_id]
|
|
).perform
|
|
|
|
render_result(result)
|
|
end
|
|
|
|
def reply_suggestion
|
|
result = Captain::ReplySuggestionService.new(
|
|
account: Current.account,
|
|
conversation_display_id: params[:conversation_display_id],
|
|
user: Current.user
|
|
).perform
|
|
|
|
render_result(result)
|
|
end
|
|
|
|
def label_suggestion
|
|
result = Captain::LabelSuggestionService.new(
|
|
account: Current.account,
|
|
conversation_display_id: params[:conversation_display_id]
|
|
).perform
|
|
|
|
render_result(result)
|
|
end
|
|
|
|
def follow_up
|
|
result = Captain::FollowUpService.new(
|
|
account: Current.account,
|
|
follow_up_context: params[:follow_up_context]&.to_unsafe_h,
|
|
user_message: params[:message],
|
|
conversation_display_id: params[:conversation_display_id]
|
|
).perform
|
|
|
|
render_result(result)
|
|
end
|
|
|
|
private
|
|
|
|
def render_result(result)
|
|
if result.nil?
|
|
render json: { message: nil }
|
|
elsif result[:error]
|
|
render json: { error: result[:error] }, status: :unprocessable_content
|
|
else
|
|
response_data = { message: result[:message] }
|
|
response_data[:follow_up_context] = result[:follow_up_context] if result[:follow_up_context]
|
|
render json: response_data
|
|
end
|
|
end
|
|
|
|
def check_authorization
|
|
authorize(:'captain/tasks')
|
|
end
|
|
end
|
|
|
|
Api::V1::Accounts::Captain::TasksController.prepend_mod_with('Api::V1::Accounts::Captain::TasksController')
|