diff --git a/nostr/nostr.go b/nostr/nostr.go index a98cb87..a93016b 100644 --- a/nostr/nostr.go +++ b/nostr/nostr.go @@ -26,6 +26,7 @@ func AddNostrAddr(n NostrRequest) { relays := make(map[string][]string) user := nostrWellKnown{} names := map[string]string{n.Name: n.Key} + if n.Relays != nil { relays = map[string][]string{n.Key: n.Relays} user = nostrWellKnown{Names: names, Relays: relays} @@ -34,12 +35,12 @@ func AddNostrAddr(n NostrRequest) { } jsonUser, _ := json.Marshal(user) - r, err := redis.New("localhost:6379", "", 0) + r, err := redis.New("localhost:6379", "", redis.NostrDb) if err != nil { fmt.Println("FAILED") } nameKey := fmt.Sprintf("%s@%s", n.Name, n.Hostname) - err = r.Client.Set(nameKey, jsonUser, 0).Err() + err = r.Client.Set(nameKey, jsonUser, redis.NostrDb).Err() if err != nil { fmt.Println("FAILED") } @@ -53,7 +54,7 @@ func GetNostrAddr(w http.ResponseWriter, req *http.Request) { req.ParseForm() // connect to redis - r, err := redis.New("localhost:6379", "", 0) + r, err := redis.New("localhost:6379", "", redis.NostrDb) if err != nil { w.WriteHeader(http.StatusNotFound) return diff --git a/redis/redis.go b/redis/redis.go index 0f27fc6..18874ed 100644 --- a/redis/redis.go +++ b/redis/redis.go @@ -2,6 +2,11 @@ package redis import "github.com/go-redis/redis" +const ( + NostrDb = iota + LndDb = iota +) + type Redis struct { Client *redis.Client }