From d55c5fa10a0c3cb6a02a82d5c187253f1694c139 Mon Sep 17 00:00:00 2001 From: Asara Date: Sat, 10 Aug 2024 23:57:58 -0400 Subject: [PATCH] fix: add 404 return codes, fix normalize domain --- matrix/matrix.go | 2 ++ nostr/nostr.go | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/matrix/matrix.go b/matrix/matrix.go index 5660a07..d146eb5 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -78,6 +78,8 @@ func MatrixClient(w http.ResponseWriter, req *http.Request) { Url: msc3575, } } + + w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(m) } diff --git a/nostr/nostr.go b/nostr/nostr.go index cefd89d..c86b48c 100644 --- a/nostr/nostr.go +++ b/nostr/nostr.go @@ -35,9 +35,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) { // normalize domain domain, _, err := net.SplitHostPort(r.Host) if err != nil { - l.Debug().Msgf("unable to split hostname %s: %s", r.Host, err.Error()) domain = r.Host - return } // get owner id for nip05 request @@ -49,6 +47,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) { err = DB.QueryRow("SELECT pubkey, relays FROM users WHERE id=$1", uid).Scan(&user.Pubkey, &user.Relays) if err != nil { l.Error().Msgf("unable to get user for uid %v: %s", uid, err.Error()) + w.WriteHeader(http.StatusNotFound) return } @@ -57,6 +56,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) { err = DB.Select(&names, "SELECT nip05s.name FROM nip05s JOIN users ON nip05s.owner_id = users.id WHERE nip05s.owner_id = $1", uid) if err != nil { l.Error().Msgf("unable to get user for uid %v: %s", uid, err.Error()) + w.WriteHeader(http.StatusNotFound) return } @@ -84,6 +84,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) { j, err := json.Marshal(ret) if err != nil { l.Error().Msg(err.Error()) + w.WriteHeader(http.StatusNotFound) return }