Fix example
This commit is contained in:
parent
3f2f4d9d59
commit
ec32643407
|
@ -1,9 +1,7 @@
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
use kuska_ssb::api::dto::content::{Post, SubsetQuery, TypedMessage};
|
use golgi::messages::SsbMessageContent;
|
||||||
|
|
||||||
use golgi::error::GolgiError;
|
use golgi::error::GolgiError;
|
||||||
use golgi::messages::{SsbMessageContent, SsbMessageValue};
|
|
||||||
use golgi::sbot::Sbot;
|
use golgi::sbot::Sbot;
|
||||||
|
|
||||||
async fn run() -> Result<(), GolgiError> {
|
async fn run() -> Result<(), GolgiError> {
|
||||||
|
@ -12,22 +10,31 @@ async fn run() -> Result<(), GolgiError> {
|
||||||
let id = sbot_client.whoami().await?;
|
let id = sbot_client.whoami().await?;
|
||||||
println!("{}", id);
|
println!("{}", id);
|
||||||
|
|
||||||
let post_msg_ref = sbot_client
|
let name = SsbMessageContent::About {
|
||||||
.publish_description("this is a description")
|
about: id,
|
||||||
.await?;
|
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);
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ pub struct SsbMessageValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SsbMessageValue {
|
impl SsbMessageValue {
|
||||||
|
|
||||||
/// Gets the type field of the message content if found,
|
/// Gets the type field of the message content if found,
|
||||||
/// and if not returns "none"
|
/// and if not returns "none"
|
||||||
pub fn get_message_type(&self) -> String {
|
pub fn get_message_type(&self) -> String {
|
||||||
|
|
|
@ -8,8 +8,7 @@ use kuska_ssb::{
|
||||||
dto::{content::SubsetQuery, CreateHistoryStreamIn},
|
dto::{content::SubsetQuery, CreateHistoryStreamIn},
|
||||||
ApiCaller,
|
ApiCaller,
|
||||||
},
|
},
|
||||||
discovery,
|
discovery, keystore,
|
||||||
keystore,
|
|
||||||
keystore::OwnedIdentity,
|
keystore::OwnedIdentity,
|
||||||
rpc::{RpcReader, RpcWriter},
|
rpc::{RpcReader, RpcWriter},
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,7 +49,6 @@ pub fn ssb_message_res_parse(body: &[u8]) -> Result<SsbMessageValue, GolgiError>
|
||||||
Ok(message)
|
Ok(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Takes in an rpc request number, and a handling function,
|
/// Takes in an rpc request number, and a handling function,
|
||||||
/// and waits for an rpc response which matches the request number,
|
/// and waits for an rpc response which matches the request number,
|
||||||
/// and then calls the handling function on the response.
|
/// and then calls the handling function on the response.
|
||||||
|
|
Loading…
Reference in New Issue