Add Tags.Has and nip11.Self
This commit is contained in:
@@ -12,6 +12,7 @@ type RelayInformationDocument struct {
|
|||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description,omitempty"`
|
||||||
PubKey *nostr.PubKey `json:"pubkey,omitempty"`
|
PubKey *nostr.PubKey `json:"pubkey,omitempty"`
|
||||||
|
Self *nostr.PubKey `json:"self,omitempty"`
|
||||||
Contact string `json:"contact,omitempty"`
|
Contact string `json:"contact,omitempty"`
|
||||||
SupportedNIPs []any `json:"supported_nips,omitempty"`
|
SupportedNIPs []any `json:"supported_nips,omitempty"`
|
||||||
Software string `json:"software,omitempty"`
|
Software string `json:"software,omitempty"`
|
||||||
|
|||||||
10
tags.go
10
tags.go
@@ -19,6 +19,16 @@ func (tags Tags) GetD() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Has returns true if a tag exists with the given key (whether or not it has a value)
|
||||||
|
func (tags Tags) Has(key string) bool {
|
||||||
|
for _, v := range tags {
|
||||||
|
if len(v) >= 1 && v[0] == key {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Find returns the first tag with the given key/tagName that also has one value (i.e. at least 2 items)
|
// Find returns the first tag with the given key/tagName that also has one value (i.e. at least 2 items)
|
||||||
func (tags Tags) Find(key string) Tag {
|
func (tags Tags) Find(key string) Tag {
|
||||||
for _, v := range tags {
|
for _, v := range tags {
|
||||||
|
|||||||
Reference in New Issue
Block a user