From ccf1688d15d68f66a5388f66bdb891f93214bb9b Mon Sep 17 00:00:00 2001 From: Cyborus Date: Tue, 18 Jun 2024 13:06:53 -0400 Subject: [PATCH] feat(user): blocking and unblocking --- src/user.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/user.rs b/src/user.rs index 31a9ef6..3010f69 100644 --- a/src/user.rs +++ b/src/user.rs @@ -38,6 +38,14 @@ pub enum UserSubcommand { /// The name of the user whose followers to list user: Option, }, + Block { + /// The name of the user to block + user: String, + }, + Unblock { + /// The name of the user to unblock + user: String, + }, } impl UserCommand { @@ -53,6 +61,8 @@ impl UserCommand { UserSubcommand::Unfollow { user } => unfollow_user(&api, &user).await?, UserSubcommand::Following { user } => list_following(&api, user.as_deref()).await?, UserSubcommand::Followers { user } => list_followers(&api, user.as_deref()).await?, + UserSubcommand::Block { user } => block_user(&api, &user).await?, + UserSubcommand::Unblock { user } => unblock_user(&api, &user).await?, } Ok(()) } @@ -238,3 +248,15 @@ async fn list_followers(api: &Forgejo, user: Option<&str>) -> eyre::Result<()> { Ok(()) } + +async fn block_user(api: &Forgejo, user: &str) -> eyre::Result<()> { + api.user_block_user(user).await?; + println!("Blocked {user}"); + Ok(()) +} + +async fn unblock_user(api: &Forgejo, user: &str) -> eyre::Result<()> { + api.user_unblock_user(user).await?; + println!("Unblocked {user}"); + Ok(()) +}