use actix_web::{HttpResponse, web}; use serde::Deserialize; use utoipa::IntoParams; use crate::api::response::{ApiErrorResponse, ApiResponse}; use crate::error::AppError; use crate::models::issues::IssueComment; use crate::service::AppService; use crate::service::issues::comments::UpdateCommentParams; use crate::session::Session; #[derive(Debug, Deserialize, IntoParams)] pub struct PathParams { pub workspace_name: String, pub number: i64, pub comment_id: uuid::Uuid, } /// Update an issue comment /// /// Updates the body of an existing comment. Only the comment author can update their own comments. /// Requires read access to the issue. /// /// Returns the updated comment with edit timestamp. #[utoipa::path( put, path = "/api/v1/workspaces/{workspace_name}/issues/{number}/comments/{comment_id}", tag = "Issues", operation_id = "issueUpdateComment", params(PathParams), request_body(content = UpdateCommentParams, description = "Comment update parameters", content_type = "application/json"), responses( (status = 200, description = "Comment updated successfully.", body = ApiResponse), (status = 400, description = "Invalid parameters: empty body", body = ApiErrorResponse), (status = 401, description = "Authentication required or session expired", body = ApiErrorResponse), (status = 403, description = "Cannot edit other users' comments", body = ApiErrorResponse), (status = 404, description = "Workspace, issue, or comment not found", body = ApiErrorResponse), (status = 500, description = "Internal server error", body = ApiErrorResponse), ), security(("session_cookie" = [])) )] pub async fn update_comment( service: web::Data, session: Session, path: web::Path, params: web::Json, ) -> Result { let comment = service .issue .issue_update_comment( &session, &path.workspace_name, path.number, path.comment_id, params.into_inner(), ) .await?; Ok(HttpResponse::Ok().json(ApiResponse::new(comment))) }