Merge pull request 'Return KVT from create_history_stream()' (#47) from return_kvt_from_history_stream into main
Reviewed-on: #47
This commit is contained in:
commit
bf7d574064
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "golgi"
|
||||
version = "0.1.4"
|
||||
version = "0.2.0"
|
||||
edition = "2021"
|
||||
authors = ["Max Fowler <max@mfowler.info>", "Andrew Reid <glyph@mycelial.technology>"]
|
||||
readme = "README.md"
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
use async_std::stream::Stream;
|
||||
use kuska_ssb::api::dto::CreateHistoryStreamIn;
|
||||
|
||||
use crate::{error::GolgiError, messages::SsbMessageValue, sbot::Sbot, utils};
|
||||
use crate::{error::GolgiError, messages::SsbMessageKVT, sbot::Sbot, utils};
|
||||
|
||||
impl Sbot {
|
||||
/// Call the `createHistoryStream` RPC method.
|
||||
/// Call the `createHistoryStream` RPC method. Returns messages in the form
|
||||
/// of KVTs (Key Value Timestamp).
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
|
@ -38,19 +39,16 @@ impl Sbot {
|
|||
pub async fn create_history_stream(
|
||||
&mut self,
|
||||
id: String,
|
||||
) -> Result<impl Stream<Item = Result<SsbMessageValue, GolgiError>>, GolgiError> {
|
||||
) -> Result<impl Stream<Item = Result<SsbMessageKVT, GolgiError>>, GolgiError> {
|
||||
let mut sbot_connection = self.get_sbot_connection().await?;
|
||||
let args = CreateHistoryStreamIn::new(id);
|
||||
let args = CreateHistoryStreamIn::new(id).keys_values(true, true);
|
||||
let req_id = sbot_connection
|
||||
.client
|
||||
.create_history_stream_req_send(&args)
|
||||
.await?;
|
||||
let history_stream = utils::get_source_stream(
|
||||
sbot_connection.rpc_reader,
|
||||
req_id,
|
||||
utils::ssb_message_res_parse,
|
||||
)
|
||||
.await;
|
||||
let history_stream =
|
||||
utils::get_source_stream(sbot_connection.rpc_reader, req_id, utils::kvt_res_parse)
|
||||
.await;
|
||||
Ok(history_stream)
|
||||
}
|
||||
}
|
||||
|
|
14
src/sbot.rs
14
src/sbot.rs
|
@ -84,18 +84,16 @@ impl Sbot {
|
|||
Keystore::CustomGoSbot(key_path) => {
|
||||
keystore::from_custom_gosbot_keypath(key_path.to_string())
|
||||
.await
|
||||
.unwrap_or_else(|_| panic!(
|
||||
"couldn't read local go-sbot secret from: {}",
|
||||
key_path
|
||||
))
|
||||
.unwrap_or_else(|_| {
|
||||
panic!("couldn't read local go-sbot secret from: {}", key_path)
|
||||
})
|
||||
}
|
||||
Keystore::CustomPatchwork(key_path) => {
|
||||
keystore::from_custom_patchwork_keypath(key_path.to_string())
|
||||
.await
|
||||
.unwrap_or_else(|_| panic!(
|
||||
"couldn't read local patchwork secret from: {}",
|
||||
key_path
|
||||
))
|
||||
.unwrap_or_else(|_| {
|
||||
panic!("couldn't read local patchwork secret from: {}", key_path)
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue