diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 46ee5f5..e8c6056 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -191,6 +191,15 @@ pub enum Commands { post_id: String, }, + /// Report a post to moderators (One-shot) + Report { + /// Post ID + post_id: String, + /// Report reason (spam, harassment, rule-violation, other) + #[arg(short, long, default_value = "spam")] + reason: String, + }, + /// Delete a post (One-shot) DeletePost { /// Post ID @@ -505,6 +514,7 @@ pub async fn execute(command: Commands, client: &MoltbookClient) -> Result<(), A Commands::DeletePost { post_id } => post::delete_post(client, &post_id).await, Commands::Upvote { post_id } => post::upvote_post(client, &post_id).await, Commands::Downvote { post_id } => post::downvote_post(client, &post_id).await, + Commands::Report { post_id, reason } => post::report_post(client, &post_id, Some(reason)).await, Commands::Search { query, type_filter, diff --git a/src/cli/post.rs b/src/cli/post.rs index 60ce527..2bfe9e3 100644 --- a/src/cli/post.rs +++ b/src/cli/post.rs @@ -290,6 +290,28 @@ pub async fn create_comment( Ok(()) } +pub async fn report_post( + client: &MoltbookClient, + post_id: &str, + reason: Option, +) -> Result<(), ApiError> { + let reason = reason.unwrap_or_else(|| "spam".to_string()); + let body = json!({ "reason": reason }); + let result: serde_json::Value = client + .post(&format!("/posts/{}/report", post_id), &body) + .await?; + + if result["success"].as_bool().unwrap_or(false) { + display::success(&format!("Post {} reported (reason: {}). 🦞", post_id, reason)); + } else { + display::error(&format!( + "Failed to report post: {}", + result["error"].as_str().unwrap_or("unknown error") + )); + } + Ok(()) +} + pub async fn upvote_comment(client: &MoltbookClient, comment_id: &str) -> Result<(), ApiError> { let result: serde_json::Value = client .post(&format!("/comments/{}/upvote", comment_id), &json!({}))