diff --git a/filter.go b/filter.go index 14d270a..bb67872 100644 --- a/filter.go +++ b/filter.go @@ -17,6 +17,7 @@ type Filter struct { Since *time.Time Until *time.Time Limit int + Search string } type TagMap map[string][]string @@ -109,5 +110,9 @@ func FilterEqual(a Filter, b Filter) bool { return false } + if a.Search != b.Search { + return false + } + return true } diff --git a/filter_aux.go b/filter_aux.go index 2f755ea..10c64f3 100644 --- a/filter_aux.go +++ b/filter_aux.go @@ -61,6 +61,8 @@ func (f *Filter) UnmarshalJSON(payload []byte) error { visiterr = fmt.Errorf("invalid 'limit' field: %w", err) } f.Limit = val + case "search": + f.Search = v.String() default: if strings.HasPrefix(key, "#") { f.Tags[key[1:]], err = fastjsonArrayToStringList(v) @@ -105,6 +107,9 @@ func (f Filter) MarshalJSON() ([]byte, error) { if f.Limit != 0 { o.Set("limit", arena.NewNumberInt(f.Limit)) } + if f.Search != "" { + o.Set("search", arena.NewString(f.Search)) + } return o.MarshalTo(nil), nil }