add unfollow and unblock methods

This commit is contained in:
glyph 2022-03-01 14:19:58 +02:00
parent 31ec2a2511
commit 6508aeb3ea
1 changed files with 60 additions and 0 deletions

View File

@ -3,7 +3,9 @@
//! Implements the following methods:
//!
//! - [`Sbot::block`]
//! - [`Sbot::unblock`]
//! - [`Sbot::follow`]
//! - [`Sbot::unfollow`]
//! - [`Sbot::friends_hops`]
//! - [`Sbot::friends_is_blocking`]
//! - [`Sbot::friends_is_following`]
@ -46,6 +48,35 @@ impl Sbot {
self.set_relationship(contact, true, false).await
}
/// Unfollow a peer.
///
/// This is a convenience method to publish a contact message with
/// following: `false` and blocking: `false`.
///
/// # Example
///
/// ```rust
/// use golgi::{Sbot, GolgiError};
///
/// async fn unfollow_peer() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?;
///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
///
/// match sbot_client.unfollow(ssb_id).await {
/// Ok(msg_ref) => {
/// println!("unfollow msg reference is: {}", msg_ref)
/// },
/// Err(e) => eprintln!("failed to unfollow {}: {}", ssb_id, e)
/// }
///
/// Ok(())
/// }
/// ```
pub async fn unfollow(&mut self, contact: &str) -> Result<String, GolgiError> {
self.set_relationship(contact, false, false).await
}
/// Block a peer.
///
/// This is a convenience method to publish a contact message with
@ -75,6 +106,35 @@ impl Sbot {
self.set_relationship(contact, false, true).await
}
/// Unblock a peer.
///
/// This is a convenience method to publish a contact message with
/// following: `false` and blocking: `false`.
///
/// # Example
///
/// ```rust
/// use golgi::{Sbot, GolgiError};
///
/// async fn unblock_peer() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?;
///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
///
/// match sbot_client.unblock(ssb_id).await {
/// Ok(msg_ref) => {
/// println!("unblock msg reference is: {}", msg_ref)
/// },
/// Err(e) => eprintln!("failed to unblock {}: {}", ssb_id, e)
/// }
///
/// Ok(())
/// }
/// ```
pub async fn unblock(&mut self, contact: &str) -> Result<String, GolgiError> {
self.set_relationship(contact, false, false).await
}
/// Publish a contact message defining the relationship for a peer.
///
/// # Example