fix: add retention to nip-11

This commit is contained in:
ZigBalthazar 2025-01-14 15:59:35 +03:30 committed by fiatjaf_
parent cb9e554fc9
commit ddd8976d3f
2 changed files with 31 additions and 8 deletions

View File

@ -28,6 +28,13 @@ func TestAddSupportedNIP(t *testing.T) {
assert.Contains(t, info.SupportedNIPs, 0, 1, 2, 12, 13, 17, 18, 19, 44)
}
func TestAddSupportedNIPs(t *testing.T) {
info := RelayInformationDocument{}
info.AddSupportedNIPs([]int{0, 1, 2, 12, 13, 17, 18, 19, 44})
assert.Contains(t, info.SupportedNIPs, 0, 1, 2, 12, 13, 17, 18, 19, 44)
}
func TestFetch(t *testing.T) {
tests := []struct {
inputURL string
@ -38,6 +45,9 @@ func TestFetch(t *testing.T) {
{"wss://nostr.wine", false, "", "wss://nostr.wine"},
{"https://nostr.wine", false, "", "wss://nostr.wine"},
{"nostr.wine", false, "", "wss://nostr.wine"},
{"jellyfish.land", false, "", "wss://jellyfish.land"},
{"https://jellyfish.land", false, "", "wss://jellyfish.land"},
{"wss://jellyfish.land", false, "", "wss://jellyfish.land"},
{"wlenwqkeqwe.asjdaskd", true, "", "wss://wlenwqkeqwe.asjdaskd"},
}

View File

@ -15,14 +15,15 @@ type RelayInformationDocument struct {
Software string `json:"software"`
Version string `json:"version"`
Limitation *RelayLimitationDocument `json:"limitation,omitempty"`
RelayCountries []string `json:"relay_countries,omitempty"`
LanguageTags []string `json:"language_tags,omitempty"`
Tags []string `json:"tags,omitempty"`
PostingPolicy string `json:"posting_policy,omitempty"`
PaymentsURL string `json:"payments_url,omitempty"`
Fees *RelayFeesDocument `json:"fees,omitempty"`
Icon string `json:"icon"`
Limitation *RelayLimitationDocument `json:"limitation,omitempty"`
RelayCountries []string `json:"relay_countries,omitempty"`
LanguageTags []string `json:"language_tags,omitempty"`
Tags []string `json:"tags,omitempty"`
PostingPolicy string `json:"posting_policy,omitempty"`
PaymentsURL string `json:"payments_url,omitempty"`
Fees *RelayFeesDocument `json:"fees,omitempty"`
Retention []*RelayRetentionDocument `json:"retention,omitempty"`
Icon string `json:"icon"`
}
func (info *RelayInformationDocument) AddSupportedNIP(number int) {
@ -34,6 +35,12 @@ func (info *RelayInformationDocument) AddSupportedNIP(number int) {
info.SupportedNIPs = append(info.SupportedNIPs, number)
}
func (info *RelayInformationDocument) AddSupportedNIPs(numbers []int) {
for _, n := range numbers {
info.AddSupportedNIP(n)
}
}
type RelayLimitationDocument struct {
MaxMessageLength int `json:"max_message_length,omitempty"`
MaxSubscriptions int `json:"max_subscriptions,omitempty"`
@ -64,3 +71,9 @@ type RelayFeesDocument struct {
Unit string `json:"unit"`
} `json:"publication,omitempty"`
}
type RelayRetentionDocument struct {
Time int64 `json:"time,omitempty"`
Count int `json:"count,omitempty"`
Kinds [][]int `json:"kinds,omitempty"`
}