mirror of
https://codeberg.org/Cyborus/forgejo-cli.git
synced 2024-11-10 12:09:33 +01:00
feat(user): blocking and unblocking
This commit is contained in:
parent
8a34e868ba
commit
ccf1688d15
1 changed files with 22 additions and 0 deletions
22
src/user.rs
22
src/user.rs
|
@ -38,6 +38,14 @@ pub enum UserSubcommand {
|
||||||
/// The name of the user whose followers to list
|
/// The name of the user whose followers to list
|
||||||
user: Option<String>,
|
user: Option<String>,
|
||||||
},
|
},
|
||||||
|
Block {
|
||||||
|
/// The name of the user to block
|
||||||
|
user: String,
|
||||||
|
},
|
||||||
|
Unblock {
|
||||||
|
/// The name of the user to unblock
|
||||||
|
user: String,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserCommand {
|
impl UserCommand {
|
||||||
|
@ -53,6 +61,8 @@ impl UserCommand {
|
||||||
UserSubcommand::Unfollow { user } => unfollow_user(&api, &user).await?,
|
UserSubcommand::Unfollow { user } => unfollow_user(&api, &user).await?,
|
||||||
UserSubcommand::Following { user } => list_following(&api, user.as_deref()).await?,
|
UserSubcommand::Following { user } => list_following(&api, user.as_deref()).await?,
|
||||||
UserSubcommand::Followers { user } => list_followers(&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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -238,3 +248,15 @@ async fn list_followers(api: &Forgejo, user: Option<&str>) -> eyre::Result<()> {
|
||||||
|
|
||||||
Ok(())
|
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(())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue