Compare commits

..

2 commits

Author SHA1 Message Date
277c713e7e fix: only enable request when lnd addr is set 2023-12-30 20:12:14 -05:00
6460002bb0 fix: nostr casing, matrix server addr 2023-12-30 19:51:27 -05:00
3 changed files with 12 additions and 7 deletions

View file

@ -32,8 +32,12 @@ func main() {
// nostr endpoints
l.Debug().Msg("enabling nostr user endpoint")
http.HandleFunc("/.well-known/nostr.json", nostr.GetNostrAddr)
l.Debug().Msg("enabling nostr request endpoint")
http.HandleFunc("/request/nostr", nostr.RequestNostrAddr)
addr := config.GetConfig().LndAddr
if addr != "" {
l.Debug().Msg("enabling nostr request endpoint")
http.HandleFunc("/request/nostr", nostr.RequestNostrAddr)
}
// start server
port := config.GetConfig().ListenAddr

View file

@ -29,7 +29,7 @@ type matrixClientWellKnown struct {
func MatrixServer(w http.ResponseWriter, req *http.Request) {
l := logger.Get()
// uses an environment variable for now
wellKnownAddr := config.GetConfig().MatrixWellKnownAddress
wellKnownAddr := fmt.Sprintf("%s:8448", config.GetConfig().MatrixWellKnownAddress)
if wellKnownAddr == "" {
w.WriteHeader(http.StatusNotFound)
l.Debug().Str("path", "matrix/server").Msg("matrix well known address unset")

View file

@ -46,9 +46,10 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "html/nostr_form.html")
case "POST":
r.ParseForm()
name := strings.ToLower(r.FormValue("Name"))
redisCli := redis.NostrRedisConn.Client
// check if the user already exists
rKey := getRkey("verified", r.FormValue("Name"), getHostname(r.Host))
rKey := getRkey("verified", name, getHostname(r.Host))
exists := redisCli.Exists(ctx, rKey)
if exists.Val() == 1 {
w.WriteHeader(http.StatusConflict)
@ -57,7 +58,7 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
})
return
}
rKey = getRkey("requested", r.FormValue("Name"), getHostname(r.Host))
rKey = getRkey("requested", name, getHostname(r.Host))
exists = redisCli.Exists(ctx, rKey)
if exists.Val() == 1 {
w.WriteHeader(http.StatusConflict)
@ -79,7 +80,7 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
// create the struct
relays := make(map[string][]string)
names := map[string]string{r.FormValue("Name"): hexKey}
names := map[string]string{name: hexKey}
user := nostrWellKnown{}
if r.FormValue("Relays") != "" {
relays = map[string][]string{
@ -150,7 +151,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
l := logger.Get()
// get query string for username
r.ParseForm()
requestedName := r.FormValue("name")
requestedName := strings.ToLower(r.FormValue("name"))
// connect to redis
redisCli := redis.NostrRedisConn.Client