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

Function admin_patch_comment_task

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

Source from the content-addressed store, hash-verified

2063}
2064
2065pub async fn admin_patch_comment_task(
2066 State(state): State<AppState>,
2067 headers: HeaderMap,
2068 Path(task_id): Path<String>,
2069 Json(request): Json<AdminPatchCommentTaskRequest>,
2070) -> Result<
2071 Json<static_flow_store::comments_store::CommentTaskRecord>,
2072 (StatusCode, Json<ErrorResponse>),
2073> {
2074 ensure_admin_access(&state, &headers)?;
2075
2076 let before = state
2077 .comment_store
2078 .get_comment_task(&task_id)
2079 .await
2080 .map_err(|e| internal_error("Failed to fetch comment task", e))?;
2081 let Some(before_task) = before else {
2082 return Err((
2083 StatusCode::NOT_FOUND,
2084 Json(ErrorResponse {
2085 error: "Comment task not found".to_string(),
2086 code: 404,
2087 }),
2088 ));
2089 };
2090
2091 let updated = state
2092 .comment_store
2093 .patch_comment_task(&task_id, CommentTaskPatch {
2094 comment_text: request.comment_text,
2095 selected_text: request.selected_text,
2096 anchor_block_id: request.anchor_block_id,
2097 anchor_context_before: request.anchor_context_before,
2098 anchor_context_after: request.anchor_context_after,
2099 admin_note: request.admin_note.clone(),
2100 })
2101 .await
2102 .map_err(|e| internal_error("Failed to patch comment task", e))?;
2103 let Some(task) = updated else {
2104 return Err((
2105 StatusCode::NOT_FOUND,
2106 Json(ErrorResponse {
2107 error: "Comment task not found".to_string(),
2108 code: 404,
2109 }),
2110 ));
2111 };
2112
2113 let operator = request.operator.unwrap_or_else(|| "admin".to_string());
2114 let _ = state
2115 .comment_store
2116 .append_audit_log(NewCommentAuditInput {
2117 log_id: generate_task_id("audit"),
2118 task_id: task_id.clone(),
2119 action: "patched".to_string(),
2120 operator,
2121 before_json: serde_json::to_string(&before_task).ok(),
2122 after_json: serde_json::to_string(&task).ok(),

Callers

nothing calls this directly

Calls 8

get_comment_taskMethod · 0.80
patch_comment_taskMethod · 0.80
cloneMethod · 0.80
append_audit_logMethod · 0.80
okMethod · 0.80
ensure_admin_accessFunction · 0.70
internal_errorFunction · 0.70
generate_task_idFunction · 0.70

Tested by

no test coverage detected