Add expiry
This commit is contained in:
parent
738511c677
commit
dc21d3850d
2 changed files with 6 additions and 6 deletions
|
@ -4,12 +4,12 @@ import (
|
||||||
"github.com/davecgh/go-spew/spew"
|
"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)
|
//redis, err := redis.New("localhost:6379", "", redis.LndDb)
|
||||||
//if err != nil {
|
//if err != nil {
|
||||||
// return "", 0, errors.New("Failed to connect to redis")
|
// return "", 0, errors.New("Failed to connect to redis")
|
||||||
//}
|
//}
|
||||||
spew.Dump(rKey)
|
spew.Dump(rKey)
|
||||||
spew.Dump(request)
|
spew.Dump(request)
|
||||||
return "x", 1, nil
|
return "x", nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.minhas.io/asara/well-goknown/lnd"
|
"git.minhas.io/asara/well-goknown/lnd"
|
||||||
"git.minhas.io/asara/well-goknown/redis"
|
"git.minhas.io/asara/well-goknown/redis"
|
||||||
|
@ -68,18 +69,17 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
|
||||||
jsonUser, _ := json.Marshal(user)
|
jsonUser, _ := json.Marshal(user)
|
||||||
|
|
||||||
// generate the payment request
|
// generate the payment request
|
||||||
paymentReq, exp, err := lnd.Request(rKey, jsonUser)
|
paymentReq, err := lnd.Request(rKey, jsonUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusServiceUnavailable)
|
w.WriteHeader(http.StatusServiceUnavailable)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
requestKey := getRkey("requested", r.FormValue("Name"), getHostname(r.Host))
|
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 {
|
if err != nil {
|
||||||
fmt.Println("FAILED")
|
fmt.Println("FAILED")
|
||||||
}
|
}
|
||||||
spew.Dump(paymentReq)
|
spew.Dump(paymentReq)
|
||||||
spew.Dump(exp)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ func AddNostrAddr(n NostrRequest) {
|
||||||
fmt.Println("Failed to connect to redis")
|
fmt.Println("Failed to connect to redis")
|
||||||
}
|
}
|
||||||
nameKey := getRkey("verified", n.Name, n.Hostname)
|
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 {
|
if err != nil {
|
||||||
fmt.Println("FAILED")
|
fmt.Println("FAILED")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue