mirror of
https://github.com/status-im/go-waku.git
synced 2025-01-27 05:56:07 +00:00
fix: handle empty content topics in filter subcribe and unsubscribe (#812)
* fix: handle empty content topics in filter subcribe and unsubscribe
This commit is contained in:
parent
bfee9964f6
commit
ac9d826b03
@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/waku-org/go-waku/waku/v2/protocol/subscription"
|
"github.com/waku-org/go-waku/waku/v2/protocol/subscription"
|
||||||
"github.com/waku-org/go-waku/waku/v2/timesource"
|
"github.com/waku-org/go-waku/waku/v2/timesource"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FilterPushID_v20beta1 is the current Waku Filter protocol identifier used to allow
|
// FilterPushID_v20beta1 is the current Waku Filter protocol identifier used to allow
|
||||||
@ -250,6 +251,9 @@ func (wf *WakuFilterLightNode) Subscribe(ctx context.Context, contentFilter prot
|
|||||||
if len(contentFilter.ContentTopics) == 0 {
|
if len(contentFilter.ContentTopics) == 0 {
|
||||||
return nil, errors.New("at least one content topic is required")
|
return nil, errors.New("at least one content topic is required")
|
||||||
}
|
}
|
||||||
|
if slices.Contains[string](contentFilter.ContentTopicsList(), "") {
|
||||||
|
return nil, errors.New("one or more content topics specified is empty")
|
||||||
|
}
|
||||||
|
|
||||||
if len(contentFilter.ContentTopics) > MaxContentTopicsPerRequest {
|
if len(contentFilter.ContentTopics) > MaxContentTopicsPerRequest {
|
||||||
return nil, fmt.Errorf("exceeds maximum content topics: %d", MaxContentTopicsPerRequest)
|
return nil, fmt.Errorf("exceeds maximum content topics: %d", MaxContentTopicsPerRequest)
|
||||||
@ -437,6 +441,10 @@ func (wf *WakuFilterLightNode) Unsubscribe(ctx context.Context, contentFilter pr
|
|||||||
return nil, errors.New("at least one content topic is required")
|
return nil, errors.New("at least one content topic is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if slices.Contains[string](contentFilter.ContentTopicsList(), "") {
|
||||||
|
return nil, errors.New("one or more content topics specified is empty")
|
||||||
|
}
|
||||||
|
|
||||||
if len(contentFilter.ContentTopics) > MaxContentTopicsPerRequest {
|
if len(contentFilter.ContentTopics) > MaxContentTopicsPerRequest {
|
||||||
return nil, fmt.Errorf("exceeds maximum content topics: %d", MaxContentTopicsPerRequest)
|
return nil, fmt.Errorf("exceeds maximum content topics: %d", MaxContentTopicsPerRequest)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user