add reactions to allowed list

This commit is contained in:
Amarpreet Minhas 2024-09-23 21:49:34 -04:00
parent fcce8eb980
commit 250680a989

View file

@ -11,7 +11,6 @@ import (
)
func RejectUnregisteredNpubs(ctx context.Context, event *nostr.Event) (reject bool, msg string) {
var err error
l := gologger.Get(config.GetConfig().LogLevel).With().Caller().Logger()
// always allow the following kinds
@ -37,11 +36,12 @@ func RejectUnregisteredNpubs(ctx context.Context, event *nostr.Event) (reject bo
// in addition to the registered users, others can use the relay for the following kinds
// as long as a registered user is tagged in the `p` tag
// 4: nip-04 encrypted dms
// 7: nip-25 reactions
// 14: nip-17 private dms
// 1059: nip-59 gift wraps
// 24133: nip-46 nostr connect
switch event.Kind {
case 4, 14, 1059, 24133:
case 4, 7, 14, 1059, 24133:
for _, npub := range event.Tags.GetAll([]string{"p"}) {
npubs = append(npubs, npub.Value())
}
@ -49,8 +49,8 @@ func RejectUnregisteredNpubs(ctx context.Context, event *nostr.Event) (reject bo
// check if npubs are registered
if authz := checknPubsInDb(npubs); authz == false {
l.Debug().Msgf("kind: %v, pubkey: %s, error: %s", event.Kind, event.PubKey, err.Error())
return true, fmt.Sprintf("restricted: pubkey %s is not registered to any users", authenticatedUser)
l.Debug().Msgf("kind: %v, pubkey: %s, unauthorized", event.Kind, event.PubKey)
return true, fmt.Sprintf("restricted: this event is not from or to any registered users/npubs")
}
return false, ""
}