diff --git a/Cargo.lock b/Cargo.lock index 2801b0a..59aa7c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -640,7 +640,6 @@ dependencies = [ [[package]] name = "kuska-ssb" version = "0.4.0" -source = "git+https://github.com/Kuska-ssb/ssb#fb7062de606e7c9cae8dd4df402a122db46c1b77" dependencies = [ "async-std", "async-stream 0.2.1", diff --git a/Cargo.toml b/Cargo.toml index 460122c..e78daf6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,8 @@ futures = "0.3.21" hex = "0.4.3" kuska-handshake = { version = "0.2.0", features = ["async_std"] } kuska-sodiumoxide = "0.2.5-0" -kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb" } +kuska-ssb = { path = "../ssb" } +#kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb" } serde = { version = "1", features = ["derive"] } serde_json = "1" sha2 = "0.10.2" diff --git a/examples/friends.rs b/examples/friends.rs index c0fcf06..87b5709 100644 --- a/examples/friends.rs +++ b/examples/friends.rs @@ -13,7 +13,17 @@ async fn run() -> Result<(), GolgiError> { // Attempt to initialise a connection to an sbot instance using the // secret file at the Patchwork path and the default IP address, port // and network key (aka. capabilities key). - let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?; + let mut sbot_client = + Sbot::init(Keystore::GoSbot, Some("127.0.0.1:8021".to_string()), None).await?; + // Sbot::init(Keystore::Patchwork, None, None).await?; + + //let ssb_id = String::from("@PEqxT8YRvrkf2fyjAgTl8pmdo8aR4KVsKLyh0b5JyOE=.ed25519"); + let ssb_id = String::from("@HEqy940T6uB+T+d9Jaa58aNfRzLx9eRWqkZljBmnkmk=.ed25519"); + + let name = sbot_client.get_name(&ssb_id).await?; + + println!("name: {}", name); + /* // Call the `whoami` RPC method to retrieve the public key for the sbot // identity. This is our 'local' public key. @@ -114,6 +124,8 @@ async fn run() -> Result<(), GolgiError> { // Output should be `false`. println!("isfollowingmref(should be false): {}", mref); + */ + Ok(()) } diff --git a/src/api/about.rs b/src/api/about.rs index d867857..4675844 100644 --- a/src/api/about.rs +++ b/src/api/about.rs @@ -13,12 +13,14 @@ use std::collections::HashMap; use async_std::stream::{Stream, StreamExt}; +use serde_json::Value; use crate::{ api::get_subset::{SubsetQuery, SubsetQueryOptions}, error::GolgiError, messages::{SsbMessageContentType, SsbMessageValue}, sbot::Sbot, + utils, }; impl Sbot { @@ -335,6 +337,7 @@ impl Sbot { Ok(profile_info) } + /* /// Get the latest `name` value for a peer. /// /// # Example @@ -359,6 +362,26 @@ impl Sbot { pub async fn get_name(&mut self, ssb_id: &str) -> Result, GolgiError> { self.get_latest_about_message(ssb_id, "name").await } + */ + + //pub async fn get_name(&mut self, ssb_id: &str) -> Result { + pub async fn get_name(&mut self, ssb_id: &str) -> Result { + let mut sbot_connection = self.get_sbot_connection().await?; + let req_id = sbot_connection + .client + .names_get_signifier_req_send(ssb_id) + //.names_get_image_for_req_send(ssb_id) + //.names_get_req_send() + .await?; + + utils::get_async( + &mut sbot_connection.rpc_reader, + req_id, + utils::string_res_parse, + //utils::json_res_parse, + ) + .await + } /// Get the latest `description` value for a peer. ///