Fix get_about_message_stream incorrect messages bug #32
@ -72,7 +72,7 @@ impl Sbot {
|
||||
// TODO: after fixing sbot regression,
|
||||
// change this subset query to filter by type about in addition to author
|
||||
// and remove this filter section
|
||||
// filter down to about messages
|
||||
// filter down to about messages
|
||||
let about_message_stream = get_subset_stream.filter(|msg| match msg {
|
||||
Ok(val) => val.is_message_type(SsbMessageContentType::About),
|
||||
Err(_err) => false,
|
||||
@ -306,20 +306,22 @@ impl Sbot {
|
||||
// for each key we are searching for, check if this about
|
||||
// message contains a value for that key
|
||||
for key in &keys_to_search_for.clone() {
|
||||
let about_val = msg.content.get("about").and_then(|val| val.as_str());
|
||||
let option_val = msg
|
||||
.content
|
||||
.get(key)
|
||||
.and_then(|val| val.as_str())
|
||||
.map(|val| val.to_string());
|
||||
match option_val {
|
||||
Some(val) => {
|
||||
// only return val if this msg is about the given ssb_id
|
||||
Some(val) if about_val == Some(ssb_id) => {
|
||||
// if a value is found, then insert it
|
||||
profile_info.insert(key.to_string(), val);
|
||||
// remove this key from keys_to_search_for,
|
||||
// since we are no longer searching for it
|
||||
keys_to_search_for.retain(|val| val != key)
|
||||
}
|
||||
None => continue,
|
||||
_ => continue,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ pub struct SsbMessageValue {
|
||||
}
|
||||
|
||||
/// Message content types.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum SsbMessageContentType {
|
||||
About,
|
||||
@ -70,12 +70,10 @@ impl SsbMessageValue {
|
||||
|
||||
/// Helper function which returns `true` if this message is of the given type,
|
||||
/// and `false` if the type does not match or is not found.
|
||||
pub fn is_message_type(&self, _message_type: SsbMessageContentType) -> bool {
|
||||
pub fn is_message_type(&self, message_type: SsbMessageContentType) -> bool {
|
||||
let self_message_type = self.get_message_type();
|
||||
match self_message_type {
|
||||
Ok(mtype) => {
|
||||
matches!(mtype, _message_type)
|
||||
}
|
||||
Ok(mtype) => mtype == message_type,
|
||||
Err(_err) => false,
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user