Add publish_post method

This commit is contained in:
notplants 2021-12-22 14:42:01 -05:00
parent ee2949f1b8
commit 5b72de0b2b
3 changed files with 13 additions and 1 deletions

View File

@ -24,6 +24,8 @@
//! }
//! ```
extern crate kuska_ssb;
pub mod error;
pub mod sbot;
mod utils;

View File

@ -113,6 +113,16 @@ impl Sbot {
utils::get_async(&mut self.rpc_reader, req_id, utils::publish_res_parse).await
}
/// Wrapper for publish which constructs and publish a post message appropriately from a string.
///
/// # Arguments
///
/// * `text` - A &str which represents the text to be published in the post
pub async fn publish_post(&mut self, text: &str) -> Result<String, GolgiError> {
let msg = TypedMessage::Post{ text: text.to_string(), mentions: None};
self.publish(msg).await
}
/*
pub async fn publish_post(&mut self, post: Post) -> Result<String, GolgiError> {
let req_id = self.client.publish_req_send(post).await?;

View File

@ -10,7 +10,7 @@ use std::fmt::Debug;
use async_std::io::Read;
use kuska_ssb::api::dto::{PublishOut, WhoAmIOut};
use kuska_ssb::api::dto::{WhoAmIOut};
use kuska_ssb::feed::Feed;
use kuska_ssb::rpc::{RecvMsg, RequestNo, RpcReader};