use actix_web::{HttpResponse, web}; use serde::Deserialize; use utoipa::IntoParams; use crate::api::response::{ApiErrorResponse, ApiResponse}; use crate::error::AppError; use crate::service::AppService; use crate::session::Session; #[derive(Debug, Deserialize, IntoParams)] pub struct PathParams { pub workspace_name: String, pub number: i64, pub comment_id: uuid::Uuid, } /// Delete an issue comment /// /// Soft-deletes a comment. The comment author can delete their own comments. /// Workspace admins can delete any comment. /// /// Effects: /// - Comment is marked as deleted /// - Issue comment count is decremented /// /// Returns success message on completion. #[utoipa::path( delete, path = "/api/v1/workspaces/{workspace_name}/issues/{number}/comments/{comment_id}", tag = "Issues", operation_id = "issueDeleteComment", params(PathParams), responses( (status = 200, description = "Comment deleted successfully.", body = ApiResponse), (status = 401, description = "Authentication required or session expired", body = ApiErrorResponse), (status = 403, description = "Cannot delete other users' comments (requires admin)", 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 delete_comment( service: web::Data, session: Session, path: web::Path, ) -> Result { service .issue .issue_delete_comment(&session, &path.workspace_name, path.number, path.comment_id) .await?; Ok(HttpResponse::Ok().json(ApiResponse::new("Comment deleted successfully".to_string()))) }