This commit is contained in:
notplants 2022-07-11 13:17:34 +02:00
commit 01138eef35
2 changed files with 3 additions and 9 deletions

1
.gitignore vendored
View File

@ -3,4 +3,3 @@ target
*peachdeploy.sh *peachdeploy.sh
*vpsdeploy.sh *vpsdeploy.sh
*bindeploy.sh *bindeploy.sh
Cargo.lock

View File

@ -8,12 +8,11 @@ use std::{
process::{Command, Output}, process::{Command, Output},
}; };
use async_std::stream::StreamExt;
use async_std::task; use async_std::task;
use dirs; use dirs;
use futures::stream::TryStreamExt; use futures::stream::TryStreamExt;
use golgi::{ use golgi::{
api::friends::RelationshipQuery, blobs, messages::SsbMessageValue, sbot::Keystore, Sbot, api::friends::RelationshipQuery, blobs, messages::SsbMessageKVT, sbot::Keystore, Sbot,
}; };
use log::debug; use log::debug;
use peach_lib::config_manager; use peach_lib::config_manager;
@ -135,11 +134,7 @@ pub fn latest_sequence_number() -> Result<u64, Box<dyn Error>> {
let id = sbot_client.whoami().await?; let id = sbot_client.whoami().await?;
let history_stream = sbot_client.create_history_stream(id).await?; let history_stream = sbot_client.create_history_stream(id).await?;
let msg_stream = history_stream.map(|res| match res { let mut msgs: Vec<SsbMessageKVT> = history_stream.try_collect().await?;
Ok(kvt) => Ok(kvt.value),
Err(err) => Err(err),
});
let mut msgs: Vec<SsbMessageValue> = msg_stream.try_collect().await?;
// there will be zero messages when the sbot is run for the first time // there will be zero messages when the sbot is run for the first time
if msgs.is_empty() { if msgs.is_empty() {
@ -149,7 +144,7 @@ pub fn latest_sequence_number() -> Result<u64, Box<dyn Error>> {
msgs.reverse(); msgs.reverse();
// return the sequence number of the latest msg // return the sequence number of the latest msg
Ok(msgs[0].sequence) Ok(msgs[0].value.sequence)
} }
}) })
} }