Skip to content

Commit

Permalink
Merge #195: nostr: filter out GenericTagValue variants that do not …
Browse files Browse the repository at this point in the history
…adhere to the spec
  • Loading branch information
yukibtc committed Nov 28, 2023
2 parents 6e6d405 + 0755ec6 commit 475d485
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/nostr/src/message/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,14 @@ where
if let (Some('#'), Some(ch), None) = (chars.next(), chars.next(), chars.next()) {
let tag: Alphabet = Alphabet::from_str(ch.to_string().as_str())
.map_err(serde::de::Error::custom)?;
let values = map.next_value()?;
let mut values: AllocSet<GenericTagValue> = map.next_value()?;

match tag {
Alphabet::P => values.retain(|v| matches!(v, GenericTagValue::Pubkey(_))),
Alphabet::E => values.retain(|v| matches!(v, GenericTagValue::EventId(_))),
_ => {}
}

generic_tags.insert(tag, values);
} else {
map.next_value::<serde::de::IgnoredAny>()?;
Expand Down

0 comments on commit 475d485

Please sign in to comment.