Working on about messages

This commit is contained in:
notplants 2021-11-16 16:15:50 +01:00
parent 4fbc22967b
commit 5fa1955b99
1 changed files with 9 additions and 3 deletions

View File

@ -343,16 +343,22 @@ impl Sbot {
.output()?;
if output.status.success() {
// TODO: figure out how to take a stream of messages, and filter down to just ones with the value we are looking for
// this code is not real dont look at it
let stdout = String::from_utf8(output.stdout)?;
let ssb_message : SsbMessageValue = serde_json::from_str(&stdout).map_err(|err| {
SbotCliError::GetAboutMsgs(format!("error deserializing ssb message while getting about message: {}", err))
})?;
let value = ssb_message.content.get(key);
match value {
Some(val) => Ok(val),
None => SbotCliError::GetAboutMsgs(format!("error parsing {} from about message: {}", key, err))
Some(val) => {
let value_as_str = val.as_str();
match value_as_str {
Some(v) => Ok(Some(v.to_string())),
None => Err(SbotCliError::GetAboutMsgs(format!("error parsing {} from about message", key)))
}
},
None => Err(SbotCliError::GetAboutMsgs(format!("error parsing {} from about message", key)))
}
Ok(value)
} else {
let stderr = std::str::from_utf8(&output.stderr)?;
// TODO: create a more generic error variant