Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] add NIP34 #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Filter struct {
Until *Timestamp `json:"until,omitempty"`
Limit int `json:"limit,omitempty"`
Search string `json:"search,omitempty"`
NIP34 string `json:"nip34,omitempty"`
}

type TagMap map[string][]string
Expand Down Expand Up @@ -113,5 +114,9 @@ func FilterEqual(a Filter, b Filter) bool {
return false
}

if a.NIP34 != b.NIP34 {
return false
}

return true
}
2 changes: 2 additions & 0 deletions filter_easyjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestFilterUnmarshal(t *testing.T) {
raw := `{"ids": ["abc"],"#e":["zzz"],"#something":["nothing","bab"],"since":1644254609,"search":"test"}`
raw := `{"ids": ["abc"],"#e":["zzz"],"#something":["nothing","bab"],"since":1644254609,"search":"test","nip34":"asc"}`
var f Filter
if err := json.Unmarshal([]byte(raw), &f); err != nil {
t.Errorf("failed to parse filter json: %v", err)
Expand All @@ -17,7 +17,7 @@ func TestFilterUnmarshal(t *testing.T) {
if f.Since == nil || f.Since.Time().UTC().Format("2006-01-02") != "2022-02-07" ||
f.Until != nil ||
f.Tags == nil || len(f.Tags) != 2 || !slices.Contains(f.Tags["something"], "bab") ||
f.Search != "test" {
f.Search != "test" || f.NIP34 != "asc" {
t.Error("failed to parse filter correctly")
}
}
Expand Down