mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
fix: add retention to nip-11
This commit is contained in:
parent
cb9e554fc9
commit
ddd8976d3f
@ -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"},
|
||||
}
|
||||
|
||||
|
@ -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"`
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user