feat: enable sane defaults

This commit is contained in:
Amarpreet Minhas 2024-08-15 19:31:27 -04:00
parent 8f880fdf7f
commit 2fdd3da9d0

View file

@ -134,8 +134,7 @@ func NewRelay(version string) *khatru.Relay {
relay.DeleteEvent = append(relay.DeleteEvent, RelayDb.DeleteEvent) relay.DeleteEvent = append(relay.DeleteEvent, RelayDb.DeleteEvent)
// apply policies // apply policies
// disabled during backporting policies.ApplySaneDefaults(relay)
//policies.ApplySaneDefaults(relay)
relay.RejectEvent = append( relay.RejectEvent = append(
relay.RejectEvent, relay.RejectEvent,
@ -153,6 +152,11 @@ func NewRelay(version string) *khatru.Relay {
func RejectUnregisteredNpubs(ctx context.Context, event *nostr.Event) (reject bool, msg string) { func RejectUnregisteredNpubs(ctx context.Context, event *nostr.Event) (reject bool, msg string) {
l := gologger.Get(config.GetConfig().LogLevel).With().Str("context", "nostr-reject-unregistered").Logger() l := gologger.Get(config.GetConfig().LogLevel).With().Str("context", "nostr-reject-unregistered").Logger()
authenticatedUser := khatru.GetAuthed(ctx)
if authenticatedUser == "" {
return true, fmt.Sprintf("auth-required: user (%s) not authed", event.PubKey)
}
// reject nip-04 messages to users who aren't registered // reject nip-04 messages to users who aren't registered
if event.Kind == 4 { if event.Kind == 4 {
@ -180,7 +184,7 @@ func RejectUnregisteredNpubs(ctx context.Context, event *nostr.Event) (reject bo
var uid int var uid int
err := DB.QueryRow("SELECT id FROM users WHERE pubkey=$1", event.PubKey).Scan(&uid) err := DB.QueryRow("SELECT id FROM users WHERE pubkey=$1", event.PubKey).Scan(&uid)
if err != nil { if err != nil {
l.Debug().Msgf("poster pubkey %s not found: %s", event.PubKey, err.Error()) l.Debug().Msgf("kind: %v, pubkey: %s, error: %s", event.Kind, event.PubKey, err.Error())
return true, fmt.Sprintf("pubkey %s is not registered to any users", event.PubKey) return true, fmt.Sprintf("pubkey %s is not registered to any users", event.PubKey)
} }
return false, "" return false, ""