support nip-35.

This commit is contained in:
fiatjaf
2022-11-26 19:31:49 -03:00
parent 2d01aa8630
commit e8bc11e4f9

View File

@ -7,6 +7,16 @@ import (
"strings" "strings"
) )
type (
Name2KeyMap map[string]string
Key2RelaysMap map[string][]string
)
type WellKnownResponse struct {
Names Name2KeyMap `json:"names"` // NIP-05
Relays Key2RelaysMap `json:"relays"` // NIP-35
}
func QueryIdentifier(fullname string) string { func QueryIdentifier(fullname string) string {
spl := strings.Split(fullname, "@") spl := strings.Split(fullname, "@")
if len(spl) != 2 { if len(spl) != 2 {
@ -20,9 +30,7 @@ func QueryIdentifier(fullname string) string {
return "" return ""
} }
var result struct { var result WellKnownResponse
Names map[string]string `json:"names"`
}
if err := json.NewDecoder(res.Body).Decode(&result); err != nil { if err := json.NewDecoder(res.Body).Decode(&result); err != nil {
return "" return ""
} }