From c12ea2c8c1e0e3a98050d93f7171df432b8144f0 Mon Sep 17 00:00:00 2001 From: notplants Date: Wed, 22 Dec 2021 16:19:52 -0500 Subject: [PATCH] Working on publish_description --- examples/ssb-client.rs | 3 +++ src/sbot.rs | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/examples/ssb-client.rs b/examples/ssb-client.rs index 3c832e4..9df337f 100644 --- a/examples/ssb-client.rs +++ b/examples/ssb-client.rs @@ -33,6 +33,9 @@ async fn run() -> Result<(), GolgiError> { let post_msg_ref = sbot_client.publish(post).await?; println!("{}", post_msg_ref); + let post_msg_ref = sbot_client.publish_description("this is a description").await?; + println!("description: {}", post_msg_ref); + Ok(()) } diff --git a/src/sbot.rs b/src/sbot.rs index aaf4788..ddfc3f7 100644 --- a/src/sbot.rs +++ b/src/sbot.rs @@ -122,6 +122,26 @@ impl Sbot { self.publish(msg).await } + + /// Wrapper for publish which constructs and publishes an about description message appropriately from a string. + /// + /// # Arguments + /// + /// * `description` - A &str which represents the text to be published as an about description. + pub async fn publish_description(&mut self, description: &str) -> Result { + let msg = TypedMessage::About { + about: self.id.to_string(), + name: None, + title: None, + branch: None, + image: None, + description: Some(description.to_string()), + location: None, + start_datetime: None, + }; + self.publish(msg).await + } + /* pub async fn publish_post(&mut self, post: Post) -> Result { let req_id = self.client.publish_req_send(post).await?;