mirror of
https://github.com/github-tijlxyz/khatru-pyramid.git
synced 2025-04-19 10:21:18 +00:00
also implement listallowedpubkeys.
This commit is contained in:
parent
0c3b4c7217
commit
7f82779f62
1
main.go
1
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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user