Repository navigation
fix(admin): accept and decode NIP-19 npub in moderation pubkey actions - #1364
Conversation
🦋 Changeset detectedLatest commit: 2b8d4f6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Confidence Score: 5/5
[Medium impact] This PR appears safe to merge.
|
Fixes #1321
Summary
normalize_pubkeyincrates/nostream-admin/src/utils/moderation.rsto trim whitespace, lowercase valid 64-character hex pubkeys, and decodenpub1…bech32 strings vianostream_core::nip19::decode_npub_hexinstead of rejecting validnpubinputs with400.require_pubkey(ban-pubkey,unban-pubkey,whitelist-pubkey,unwhitelist-pubkey) andnormalize(PATCH /admin/moderation/limits) tonormalize_pubkey, keepingPUBKEY_REQUIRED("pubkey is required and must be a 64-character hex pubkey or npub") aligned with the UI label/prompt.crates/nostream-admin/src/utils/moderation.rsand integration tests incrates/nostream-admin/tests/write_path.rscovering:POST /admin/moderation/actionsbanning a validnpub1…and persisting its lowercase hex pubkey/admin/(Pubkey or npub,hex or npub),/admin/assets/admin-moderation.js(Enter a pubkey or npub to ban.), and the400refusal response match the accepted forms.Verification
cargo fmt --all --checkcargo clippy -p nostream-admin --all-targets --all-features -- -D warningscargo clippy -p nostream-admin --lib --bins --all-features -- -D warnings -D clippy::unwrap_used -D clippy::expect_used -D clippy::todo -D clippy::unimplemented -D clippy::paniccargo test -p nostream-admin --all-features