mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-05-02 23:00:14 +02:00
Handle Filter.Limit
This commit is contained in:
parent
e546214291
commit
e47c80a63d
@ -55,6 +55,12 @@ func (f *Filter) UnmarshalJSON(payload []byte) error {
|
||||
}
|
||||
tm := time.Unix(val, 0)
|
||||
f.Until = &tm
|
||||
case "limit":
|
||||
val, err := v.Int()
|
||||
if err != nil {
|
||||
visiterr = fmt.Errorf("invalid 'limit' field: %w", err)
|
||||
}
|
||||
f.Limit = val
|
||||
default:
|
||||
if strings.HasPrefix(key, "#") {
|
||||
f.Tags[key[1:]], err = fastjsonArrayToStringList(v)
|
||||
@ -96,6 +102,9 @@ func (f Filter) MarshalJSON() ([]byte, error) {
|
||||
o.Set("#"+k, stringListToFastjsonArray(&arena, v))
|
||||
}
|
||||
}
|
||||
if f.Limit != 0 {
|
||||
o.Set("limit", arena.NewNumberInt(f.Limit))
|
||||
}
|
||||
|
||||
return o.MarshalTo(nil), nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user