feat: add event kind blacklist

Adds a list to the config where you can specify which event kinds to blacklist.
The blacklist check will run right after verifying that the pubkey is allowed
to post events to the relay.
This commit is contained in:
0xtr
2022-12-27 17:10:34 -06:00
committed by Greg Heartsfield
parent 104ef2b9e1
commit 7774db8c47
3 changed files with 26 additions and 1 deletions
+19 -1
View File
@@ -232,6 +232,24 @@ pub async fn db_writer(
}
}
// Check that event kind isn't blacklisted
let kinds_blacklist = &settings.limits.event_kind_blacklist.clone();
if let Some(event_kind_blacklist) = kinds_blacklist {
if event_kind_blacklist.contains(&event.kind) {
info!(
"Rejecting event {}, blacklisted kind",
&event.get_event_id_prefix()
);
notice_tx
.try_send(Notice::blocked(
event.id,
"event kind is blocked by relay"
))
.ok();
continue;
}
}
// send any metadata events to the NIP-05 verifier
if nip05_active && event.is_kind_metadata() {
// we are sending this prior to even deciding if we
@@ -901,4 +919,4 @@ pub async fn db_query(
let ok: Result<()> = Ok(());
ok
});
}
}