Add expiry

This commit is contained in:
Amarpreet Minhas 2023-02-04 22:24:30 -05:00
parent 738511c677
commit dc21d3850d
2 changed files with 6 additions and 6 deletions

View file

@ -4,12 +4,12 @@ import (
"github.com/davecgh/go-spew/spew"
)
func Request(rKey string, request []byte) (string, int, error) {
func Request(rKey string, request []byte) (string, error) {
//redis, err := redis.New("localhost:6379", "", redis.LndDb)
//if err != nil {
// return "", 0, errors.New("Failed to connect to redis")
//}
spew.Dump(rKey)
spew.Dump(request)
return "x", 1, nil
return "x", nil
}

View file

@ -7,6 +7,7 @@ import (
"fmt"
"net/http"
"strings"
"time"
"git.minhas.io/asara/well-goknown/lnd"
"git.minhas.io/asara/well-goknown/redis"
@ -68,18 +69,17 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
jsonUser, _ := json.Marshal(user)
// generate the payment request
paymentReq, exp, err := lnd.Request(rKey, jsonUser)
paymentReq, err := lnd.Request(rKey, jsonUser)
if err != nil {
w.WriteHeader(http.StatusServiceUnavailable)
return
}
requestKey := getRkey("requested", r.FormValue("Name"), getHostname(r.Host))
err = redisCli.Client.Set(ctx, requestKey, jsonUser, redis.NostrDb).Err()
err = redisCli.Client.Set(ctx, requestKey, jsonUser, 15*time.Minute).Err()
if err != nil {
fmt.Println("FAILED")
}
spew.Dump(paymentReq)
spew.Dump(exp)
}
}
@ -134,7 +134,7 @@ func AddNostrAddr(n NostrRequest) {
fmt.Println("Failed to connect to redis")
}
nameKey := getRkey("verified", n.Name, n.Hostname)
err = redisCli.Client.Set(ctx, nameKey, jsonUser, redis.NostrDb).Err()
err = redisCli.Client.Set(ctx, nameKey, jsonUser, 0).Err()
if err != nil {
fmt.Println("FAILED")
}