(
article_id: Option<&str>,
task_id: Option<&str>,
limit: Option<usize>,
offset: Option<usize>,
)
| 4284 | } |
| 4285 | |
| 4286 | pub async fn fetch_admin_published_comments( |
| 4287 | article_id: Option<&str>, |
| 4288 | task_id: Option<&str>, |
| 4289 | limit: Option<usize>, |
| 4290 | offset: Option<usize>, |
| 4291 | ) -> Result<AdminCommentPublishedResponse, String> { |
| 4292 | #[cfg(feature = "mock")] |
| 4293 | { |
| 4294 | let _ = (article_id, task_id, limit, offset); |
| 4295 | Ok(AdminCommentPublishedResponse { |
| 4296 | comments: vec![], |
| 4297 | total: 0, |
| 4298 | offset: 0, |
| 4299 | has_more: false, |
| 4300 | }) |
| 4301 | } |
| 4302 | |
| 4303 | #[cfg(not(feature = "mock"))] |
| 4304 | { |
| 4305 | let mut url = format!("{}/admin/comments/published", admin_base()); |
| 4306 | let mut params = Vec::new(); |
| 4307 | if let Some(article_id) = article_id.map(str::trim).filter(|value| !value.is_empty()) { |
| 4308 | params.push(format!("article_id={}", urlencoding::encode(article_id))); |
| 4309 | } |
| 4310 | if let Some(task_id) = task_id.map(str::trim).filter(|value| !value.is_empty()) { |
| 4311 | params.push(format!("task_id={}", urlencoding::encode(task_id))); |
| 4312 | } |
| 4313 | if let Some(limit) = limit { |
| 4314 | params.push(format!("limit={limit}")); |
| 4315 | } |
| 4316 | if let Some(offset) = offset { |
| 4317 | params.push(format!("offset={offset}")); |
| 4318 | } |
| 4319 | if !params.is_empty() { |
| 4320 | url.push('?'); |
| 4321 | url.push_str(¶ms.join("&")); |
| 4322 | } |
| 4323 | |
| 4324 | let response = api_get(&url) |
| 4325 | .send() |
| 4326 | .await |
| 4327 | .map_err(|e| format!("Network error: {:?}", e))?; |
| 4328 | if !response.ok() { |
| 4329 | return Err(format!("HTTP error: {}", response.status())); |
| 4330 | } |
| 4331 | response |
| 4332 | .json() |
| 4333 | .await |
| 4334 | .map_err(|e| format!("Parse error: {:?}", e)) |
| 4335 | } |
| 4336 | } |
| 4337 | |
| 4338 | pub async fn patch_admin_published_comment( |
| 4339 | comment_id: &str, |
no test coverage detected