use actix_web::{HttpResponse, Result, web}; use service::AppService; use session::Session; use crate::ApiResponse; #[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)] pub struct TriageIssueQuery { pub issue_number: i64, } #[utoipa::path( get, path = "/api/agents/{project}/triage", params( ("project" = String, Path, description = "Project name"), ("issue_number" = i64, Query, description = "Issue number to triage"), ), responses( (status = 200, description = "Issue triage result", body = ApiResponse), (status = 401, description = "Unauthorized"), (status = 404, description = "Issue not found"), ), tag = "Agent" )] pub async fn triage_issue( service: web::Data, session: Session, path: web::Path, query: web::Query, ) -> Result { let project_name = path.into_inner(); let user_id = session.user().ok_or(crate::error::ApiError( service::error::AppError::Unauthorized, ))?; let project = service .utils_find_project_by_name(project_name.clone()) .await?; // Verify user has access to the project before triggering AI triage service .check_project_access(project.id, user_id) .await .map_err(|e| crate::error::ApiError(e))?; let resp = service .triage_issue(project_name, query.issue_number) .await?; Ok(crate::ApiResponse::ok(resp).to_response()) }