diff --git a/main.go b/main.go index 268f64c..948628a 100644 --- a/main.go +++ b/main.go @@ -92,6 +92,7 @@ func main() { relay.ManagementAPI.AllowPubKey = allowPubKeyHandler relay.ManagementAPI.BanPubKey = banPubKeyHandler + relay.ManagementAPI.ListAllowedPubKeys = listAllowedPubKeysHandler // load users registry if err := loadWhitelist(); err != nil { diff --git a/management.go b/management.go index 265042c..1baf98c 100644 --- a/management.go +++ b/management.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/fiatjaf/khatru" + "github.com/nbd-wtf/go-nostr/nip86" ) func allowPubKeyHandler(ctx context.Context, pubkey, reason string) error { @@ -36,3 +37,13 @@ func banPubKeyHandler(ctx context.Context, pubkey, reason string) error { return saveWhitelist() } + +func listAllowedPubKeysHandler(ctx context.Context) ([]nip86.PubKeyReason, error) { + list := make([]nip86.PubKeyReason, len(whitelist)) + i := 0 + for pubkey, inviter := range whitelist { + list[i] = nip86.PubKeyReason{PubKey: pubkey, Reason: fmt.Sprintf("invited by %s", inviter)} + i++ + } + return list, nil +}