refactor(api): reorder imports and update code formatting across repository endpoints
- Reordered actix-web imports to standardize import order - Reordered crate module imports to follow alphabetical ordering - Updated function calls to use multi-line formatting for better readability - Standardized blank lines around documentation comments - Applied consistent formatting to response handling methods - Normalized import organization across all repository-related API files - Improved code consistency and maintainability through standardized formatting - Applied formatting updates to all repository endpoint implementations
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
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<String>),
|
||||
(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<AppService>,
|
||||
session: Session,
|
||||
path: web::Path<PathParams>,
|
||||
) -> Result<HttpResponse, AppError> {
|
||||
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())))
|
||||
}
|
||||
Reference in New Issue
Block a user