2022-01-16 14:51:54 +00:00
|
|
|
use std::process;
|
|
|
|
|
2022-02-04 08:16:45 +00:00
|
|
|
use kuska_ssb::api::dto::content::PubAddress;
|
|
|
|
|
2022-01-16 14:51:54 +00:00
|
|
|
use golgi::error::GolgiError;
|
|
|
|
use golgi::messages::SsbMessageContent;
|
|
|
|
use golgi::sbot::Sbot;
|
|
|
|
|
|
|
|
async fn run() -> Result<(), GolgiError> {
|
2022-02-07 12:44:36 +00:00
|
|
|
let mut sbot_client = Sbot::connect(None, None).await?;
|
2022-01-16 14:51:54 +00:00
|
|
|
|
|
|
|
let id = sbot_client.whoami().await?;
|
|
|
|
println!("whoami: {}", id);
|
|
|
|
|
2022-02-04 08:16:45 +00:00
|
|
|
// publish a pub address message (in order to test accepting invite from other client)
|
|
|
|
let pub_address_msg = SsbMessageContent::Pub {
|
|
|
|
address: Some(PubAddress {
|
|
|
|
host: Some("127.0.0.1".to_string()),
|
|
|
|
port: 8009,
|
|
|
|
key: id,
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
|
|
|
|
let pub_msg_ref = sbot_client.publish(pub_address_msg).await?;
|
|
|
|
println!("pub_msg_ref: {}", pub_msg_ref);
|
|
|
|
|
|
|
|
let invite_code = sbot_client.invite_create(1).await?;
|
|
|
|
println!("invite (1 use): {:?}", invite_code);
|
|
|
|
|
|
|
|
let invite_code_2 = sbot_client.invite_create(7).await?;
|
|
|
|
println!("invite (7 uses): {:?}", invite_code_2);
|
2022-01-16 14:51:54 +00:00
|
|
|
|
2022-02-04 08:16:45 +00:00
|
|
|
let test_invite =
|
|
|
|
"net:ssbroom2.commoninternet.net:8009~shs:wm8a1zHWjtESv4XSKMWU/rPRhnAoAiSAe4hQSY0UF5A=";
|
2022-01-16 14:51:54 +00:00
|
|
|
let mref = sbot_client.invite_use(test_invite).await?;
|
|
|
|
println!("mref: {:?}", mref);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_std::main]
|
|
|
|
async fn main() {
|
|
|
|
if let Err(e) = run().await {
|
|
|
|
eprintln!("Application error: {}", e);
|
|
|
|
process::exit(1);
|
|
|
|
}
|
|
|
|
}
|