From 9ba61b56e6d89ec403cc51e2f900f488188fbda1 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Sat, 27 Sep 2025 06:37:06 -0700 Subject: [PATCH] Add Tags.Has and nip11.Self --- nip11/types.go | 1 + tags.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/nip11/types.go b/nip11/types.go index 4c81885..4347155 100644 --- a/nip11/types.go +++ b/nip11/types.go @@ -12,6 +12,7 @@ type RelayInformationDocument struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` PubKey *nostr.PubKey `json:"pubkey,omitempty"` + Self *nostr.PubKey `json:"self,omitempty"` Contact string `json:"contact,omitempty"` SupportedNIPs []any `json:"supported_nips,omitempty"` Software string `json:"software,omitempty"` diff --git a/tags.go b/tags.go index 54d627e..d61609d 100644 --- a/tags.go +++ b/tags.go @@ -19,6 +19,16 @@ func (tags Tags) GetD() string { 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) func (tags Tags) Find(key string) Tag { for _, v := range tags {