(
task_id: &str,
request: &AdminTaskActionRequest,
)
| 4253 | } |
| 4254 | |
| 4255 | pub async fn admin_delete_comment_task( |
| 4256 | task_id: &str, |
| 4257 | request: &AdminTaskActionRequest, |
| 4258 | ) -> Result<serde_json::Value, String> { |
| 4259 | #[cfg(feature = "mock")] |
| 4260 | { |
| 4261 | let _ = request; |
| 4262 | Ok(serde_json::json!({ "task_id": task_id, "deleted": true })) |
| 4263 | } |
| 4264 | |
| 4265 | #[cfg(not(feature = "mock"))] |
| 4266 | { |
| 4267 | let url = |
| 4268 | format!("{}/admin/comments/tasks/{}", admin_base(), urlencoding::encode(task_id),); |
| 4269 | let response = api_delete(&url) |
| 4270 | .header("Content-Type", "application/json") |
| 4271 | .json(request) |
| 4272 | .map_err(|e| format!("Serialize error: {:?}", e))? |
| 4273 | .send() |
| 4274 | .await |
| 4275 | .map_err(|e| format!("Network error: {:?}", e))?; |
| 4276 | if !response.ok() { |
| 4277 | return Err(format!("HTTP error: {}", response.status())); |
| 4278 | } |
| 4279 | response |
| 4280 | .json() |
| 4281 | .await |
| 4282 | .map_err(|e| format!("Parse error: {:?}", e)) |
| 4283 | } |
| 4284 | } |
| 4285 | |
| 4286 | pub async fn fetch_admin_published_comments( |
| 4287 | article_id: Option<&str>, |
no test coverage detected