summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-12-06 20:43:25 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-12-09 11:13:00 +0100
commit7ed34f04b41f8c575f4ab5a178495a7132c39947 (patch)
tree0d087f2bfb86203b2a5fe74fcab0e33de213e8b0
parent78e0434b653700621157eb4db40e81eea99fa2c5 (diff)
Add function to post text to profile
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--lib/src/profile/mod.rs13
1 files changed, 13 insertions, 0 deletions
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<cid::Cid> {
+ let parent = self.state
+ .profile_head()
+ .as_ref()
+ .map(cid::Cid::clone)
+ .into_iter()
+ .collect::<Vec<cid::Cid>>();
+
+ 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<PathBuf> {
let path = state_dir.ipfs();
tokio::fs::create_dir_all(&path).await?;