diff --git a/CHANGELOG.md b/CHANGELOG.md index 92a98f05f..af2b5d8b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +* nostr: add `Report::Other` variant ([Daniel Cadenas]) * cli: add command to serve `Nostr Connect` signer ([Yuki Kishimoto]) * ffi(nostr): added `FilterRecord`, to allow to access fields in `Filter` ([Yuki Kishimoto]) * ffi(sdk): add `AbortHandle` ([Yuki Kishimoto]) @@ -64,6 +65,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [Yuki Kishimoto]: https://yukikishimoto.com [DanConwayDev]: https://github.com/DanConwayDev +[Daniel Cadenas]: https://github.com/dcadenas [Unreleased]: https://github.com/rust-nostr/nostr/compare/v0.29.0...HEAD diff --git a/bindings/nostr-ffi/src/event/tag.rs b/bindings/nostr-ffi/src/event/tag.rs index f7d6dab9a..455751328 100644 --- a/bindings/nostr-ffi/src/event/tag.rs +++ b/bindings/nostr-ffi/src/event/tag.rs @@ -74,6 +74,8 @@ pub enum Report { Spam, /// Someone pretending to be someone else Impersonation, + /// Reports that don't fit in the above categories + Other, } impl From for tag::Report { @@ -84,6 +86,7 @@ impl From for tag::Report { Report::Illegal => Self::Illegal, Report::Spam => Self::Spam, Report::Impersonation => Self::Impersonation, + Report::Other => Self::Other, } } } @@ -96,6 +99,7 @@ impl From for Report { tag::Report::Illegal => Self::Illegal, tag::Report::Spam => Self::Spam, tag::Report::Impersonation => Self::Impersonation, + tag::Report::Other => Self::Other, } } } diff --git a/crates/nostr/src/event/tag.rs b/crates/nostr/src/event/tag.rs index 65505cbac..b7a0bfa7b 100644 --- a/crates/nostr/src/event/tag.rs +++ b/crates/nostr/src/event/tag.rs @@ -215,6 +215,8 @@ pub enum Report { Spam, /// Someone pretending to be someone else Impersonation, + /// Reports that don't fit in the above categories + Other, } impl fmt::Display for Report { @@ -225,6 +227,7 @@ impl fmt::Display for Report { Self::Illegal => write!(f, "illegal"), Self::Spam => write!(f, "spam"), Self::Impersonation => write!(f, "impersonation"), + Self::Other => write!(f, "other"), } } } @@ -239,6 +242,7 @@ impl FromStr for Report { "illegal" => Ok(Self::Illegal), "spam" => Ok(Self::Spam), "impersonation" => Ok(Self::Impersonation), + "other" => Ok(Self::Other), _ => Err(Error::UnknownReportType), } } @@ -2202,6 +2206,22 @@ mod tests { ) ); + assert_eq!( + Tag::parse(&[ + "p", + "13adc511de7e1cfcf1c6b7f6365fb5a03442d7bcacf565ea57fa7770912c023d", + "other" + ]) + .unwrap(), + Tag::PubKeyReport( + PublicKey::from_str( + "13adc511de7e1cfcf1c6b7f6365fb5a03442d7bcacf565ea57fa7770912c023d" + ) + .unwrap(), + Report::Other + ) + ); + assert_eq!( Tag::parse(&[ "e",