support nip-35.

This commit is contained in:
fiatjaf 2022-11-26 19:31:49 -03:00
parent 2d01aa8630
commit e8bc11e4f9
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1

View File

@ -7,6 +7,16 @@ import (
"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 {
spl := strings.Split(fullname, "@")
if len(spl) != 2 {
@ -20,9 +30,7 @@ func QueryIdentifier(fullname string) string {
return ""
}
var result struct {
Names map[string]string `json:"names"`
}
var result WellKnownResponse
if err := json.NewDecoder(res.Body).Decode(&result); err != nil {
return ""
}