From 7ed34f04b41f8c575f4ab5a178495a7132c39947 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 6 Dec 2021 20:43:25 +0100 Subject: Add function to post text to profile Signed-off-by: Matthias Beyer --- lib/src/profile/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/src/profile/mod.rs b/lib/src/profile/mod.rs index db3c593..050d53d 100644 --- a/lib/src/profile/mod.rs +++ b/lib/src/profile/mod.rs @@ -66,6 +66,19 @@ impl Profile { self.client.connect(peer).await } + pub async fn post_text(&mut self, text: String) -> Result { + let parent = self.state + .profile_head() + .as_ref() + .map(cid::Cid::clone) + .into_iter() + .collect::>(); + + let new_cid = self.client.post_text_node(parent, text).await?; + self.state.update_head(new_cid.clone())?; + Ok(new_cid) + } + async fn ipfs_path(state_dir: &StateDir) -> Result { let path = state_dir.ipfs(); tokio::fs::create_dir_all(&path).await?; -- cgit v1.2.3