MCPcopy Create free account
hub / github.com/acking-you/static_flow / admin_delete_comment_task

Function admin_delete_comment_task

crates/backend/src/handlers.rs:2556–2605  ·  view source on GitHub ↗
(
    State(state): State<AppState>,
    headers: HeaderMap,
    Path(task_id): Path<String>,
    Json(request): Json<AdminTaskActionRequest>,
)

Source from the content-addressed store, hash-verified

2554}
2555
2556pub async fn admin_delete_comment_task(
2557 State(state): State<AppState>,
2558 headers: HeaderMap,
2559 Path(task_id): Path<String>,
2560 Json(request): Json<AdminTaskActionRequest>,
2561) -> Result<Json<serde_json::Value>, (StatusCode, Json<ErrorResponse>)> {
2562 ensure_admin_access(&state, &headers)?;
2563
2564 let before = state
2565 .comment_store
2566 .get_comment_task(&task_id)
2567 .await
2568 .map_err(|e| internal_error("Failed to fetch comment task", e))?;
2569 let Some(before_task) = before else {
2570 return Err((
2571 StatusCode::NOT_FOUND,
2572 Json(ErrorResponse {
2573 error: "Comment task not found".to_string(),
2574 code: 404,
2575 }),
2576 ));
2577 };
2578 if before_task.status == COMMENT_STATUS_RUNNING {
2579 return Err(conflict_error("Running comment task cannot be deleted"));
2580 }
2581
2582 state
2583 .comment_store
2584 .delete_comment_task(&task_id)
2585 .await
2586 .map_err(|e| internal_error("Failed to delete comment task", e))?;
2587
2588 let operator = request.operator.unwrap_or_else(|| "admin".to_string());
2589 let _ = state
2590 .comment_store
2591 .append_audit_log(NewCommentAuditInput {
2592 log_id: generate_task_id("audit"),
2593 task_id: task_id.clone(),
2594 action: "task_deleted".to_string(),
2595 operator,
2596 before_json: serde_json::to_string(&before_task).ok(),
2597 after_json: Some("{\"deleted\":true}".to_string()),
2598 })
2599 .await;
2600
2601 Ok(Json(serde_json::json!({
2602 "task_id": task_id,
2603 "deleted": true
2604 })))
2605}
2606
2607pub async fn admin_list_comment_audit_logs(
2608 State(state): State<AppState>,

Callers

nothing calls this directly

Calls 9

get_comment_taskMethod · 0.80
delete_comment_taskMethod · 0.80
append_audit_logMethod · 0.80
cloneMethod · 0.80
okMethod · 0.80
ensure_admin_accessFunction · 0.70
internal_errorFunction · 0.70
conflict_errorFunction · 0.70
generate_task_idFunction · 0.70

Tested by

no test coverage detected