Skip to content

Commit

Permalink
nostr: add Report::Other variant
Browse files Browse the repository at this point in the history
Adds a new `Report::Other` variant to sync with NIP56

Closes #393

Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
dcadenas authored and yukibtc committed Apr 5, 2024
1 parent c70fd11 commit 9da9ab5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -64,6 +65,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<!-- Contributors -->
[Yuki Kishimoto]: https://yukikishimoto.com
[DanConwayDev]: https://github.com/DanConwayDev
[Daniel Cadenas]: https://github.com/dcadenas

<!-- Tags -->
[Unreleased]: https://github.com/rust-nostr/nostr/compare/v0.29.0...HEAD
4 changes: 4 additions & 0 deletions bindings/nostr-ffi/src/event/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Report> for tag::Report {
Expand All @@ -84,6 +86,7 @@ impl From<Report> for tag::Report {
Report::Illegal => Self::Illegal,
Report::Spam => Self::Spam,
Report::Impersonation => Self::Impersonation,
Report::Other => Self::Other,
}
}
}
Expand All @@ -96,6 +99,7 @@ impl From<tag::Report> for Report {
tag::Report::Illegal => Self::Illegal,
tag::Report::Spam => Self::Spam,
tag::Report::Impersonation => Self::Impersonation,
tag::Report::Other => Self::Other,
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions crates/nostr/src/event/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"),
}
}
}
Expand All @@ -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),
}
}
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 9da9ab5

Please sign in to comment.