Fix example

This commit is contained in:
notplants 2021-12-29 11:38:03 -05:00
parent 3f2f4d9d59
commit ec32643407
4 changed files with 25 additions and 21 deletions

View File

@ -1,9 +1,7 @@
use std::process;
use kuska_ssb::api::dto::content::{Post, SubsetQuery, TypedMessage};
use golgi::messages::SsbMessageContent;
use golgi::error::GolgiError;
use golgi::messages::{SsbMessageContent, SsbMessageValue};
use golgi::sbot::Sbot;
async fn run() -> Result<(), GolgiError> {
@ -12,22 +10,31 @@ async fn run() -> Result<(), GolgiError> {
let id = sbot_client.whoami().await?;
println!("{}", id);
let post_msg_ref = sbot_client
.publish_description("this is a description")
.await?;
let name = SsbMessageContent::About {
about: id,
name: Some("golgi".to_string()),
title: None,
branch: None,
image: None,
description: None,
location: None,
start_datetime: None,
};
let name_msg_ref = sbot_client.publish(name).await?;
println!("{}", name_msg_ref);
let post = SsbMessageContent::Post {
text: "golgi go womp womp".to_string(),
mentions: None,
};
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);
let author = "@L/z54cbc8V1kL1/MiBhpEKuN3QJkSoZYNaukny3ghIs=.ed25519".to_string();
println!("Calling create_history");
let messages: Vec<SsbMessageValue> = sbot_client.create_history_stream(author).await?;
println!("hist: {:?}", messages);
for message in messages {
let content: SsbMessageContent = message.into_ssb_message_content()?;
println!("content: {:?}", content);
}
Ok(())
}

View File

@ -30,7 +30,6 @@ pub struct SsbMessageValue {
}
impl SsbMessageValue {
/// Gets the type field of the message content if found,
/// and if not returns "none"
pub fn get_message_type(&self) -> String {

View File

@ -8,8 +8,7 @@ use kuska_ssb::{
dto::{content::SubsetQuery, CreateHistoryStreamIn},
ApiCaller,
},
discovery,
keystore,
discovery, keystore,
keystore::OwnedIdentity,
rpc::{RpcReader, RpcWriter},
};

View File

@ -49,7 +49,6 @@ pub fn ssb_message_res_parse(body: &[u8]) -> Result<SsbMessageValue, GolgiError>
Ok(message)
}
/// Takes in an rpc request number, and a handling function,
/// and waits for an rpc response which matches the request number,
/// and then calls the handling function on the response.