commands to ban (and unban) events using the relay management api.

This commit is contained in:
fiatjaf
2024-11-25 12:04:30 -03:00
parent 762018edf6
commit 1b2e434d6a
6 changed files with 202 additions and 23 deletions

View File

@@ -72,6 +72,14 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
return
}
if banned, reason := internal.isBanned(data.event.ID); banned {
w.Header().Set("Cache-Control", "max-age=60")
log.Warn().Err(err).Str("code", code).Str("reason", reason).Msg("event banned")
w.WriteHeader(http.StatusNotFound)
errorTemplate(ErrorPageParams{Errors: "event banned"}).Render(ctx, w)
return
}
// if we originally got a note code or an nevent with no hints
// augment the URL to point to an nevent with hints -- redirect
if p, ok := decoded.(nostr.EventPointer); (ok && p.Author == "" && len(p.Relays) == 0) || prefix == "note" {