mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 13:22:56 +01:00
fix sonic parsing req envelopes with limit/since/until.
This commit is contained in:
parent
4dcadd4d88
commit
c64ebde59d
@ -447,10 +447,13 @@ func (sv *sonicVisitor) OnInt64(v int64, _ stdlibjson.Number) error {
|
|||||||
case inLimit:
|
case inLimit:
|
||||||
sv.currentFilter.Limit = int(v)
|
sv.currentFilter.Limit = int(v)
|
||||||
sv.currentFilter.LimitZero = v == 0
|
sv.currentFilter.LimitZero = v == 0
|
||||||
|
sv.whereWeAre = inFilterObject
|
||||||
case inSince:
|
case inSince:
|
||||||
sv.currentFilter.Since = (*Timestamp)(&v)
|
sv.currentFilter.Since = (*Timestamp)(&v)
|
||||||
|
sv.whereWeAre = inFilterObject
|
||||||
case inUntil:
|
case inUntil:
|
||||||
sv.currentFilter.Until = (*Timestamp)(&v)
|
sv.currentFilter.Until = (*Timestamp)(&v)
|
||||||
|
sv.whereWeAre = inFilterObject
|
||||||
case inKinds:
|
case inKinds:
|
||||||
sv.currentFilter.Kinds = append(sv.currentFilter.Kinds, int(v))
|
sv.currentFilter.Kinds = append(sv.currentFilter.Kinds, int(v))
|
||||||
|
|
||||||
|
@ -106,6 +106,16 @@ func TestParseMessage(t *testing.T) {
|
|||||||
Message: `["CLOSE","subscription123"]`,
|
Message: `["CLOSE","subscription123"]`,
|
||||||
ExpectedEnvelope: ptr(CloseEnvelope("subscription123")),
|
ExpectedEnvelope: ptr(CloseEnvelope("subscription123")),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "AUTH envelope from nak 23gmt bug",
|
||||||
|
Message: `["AUTH","c45b2b06ad92e28a"]`,
|
||||||
|
ExpectedEnvelope: &AuthEnvelope{Challenge: ptr("c45b2b06ad92e28a")},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "REQ from jumble",
|
||||||
|
Message: `["REQ","sub:1",{"kinds":[1,6],"limit":100}]`,
|
||||||
|
ExpectedEnvelope: &ReqEnvelope{SubscriptionID: "sub:1", Filters: Filters{{Kinds: []int{1, 6}, Limit: 100}}},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("standard", func(t *testing.T) {
|
t.Run("standard", func(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user