This commit is contained in:
Dominik Hirzel 2017-06-08 08:17:14 +00:00 committed by GitHub
commit 49928d3898

View file

@ -163,6 +163,8 @@ func parseRequest(incomingMsg json.RawMessage) ([]rpcRequest, bool, Error) {
return nil, false, &invalidMessageError{err.Error()}
}
// shh_subscribe should not be handled in a special way
if !strings.HasPrefix(in.Method, "shh_") {
// subscribe are special, they will always use `subscribeMethod` as first param in the payload
if strings.HasSuffix(in.Method, subscribeMethodSuffix) {
reqs := []rpcRequest{{id: &in.Id, isPubSub: true}}
@ -180,6 +182,7 @@ func parseRequest(incomingMsg json.RawMessage) ([]rpcRequest, bool, Error) {
}
return nil, false, &invalidRequestError{"Unable to parse subscription request"}
}
}
if strings.HasSuffix(in.Method, unsubscribeMethodSuffix) {
return []rpcRequest{{id: &in.Id, isPubSub: true,
@ -215,6 +218,8 @@ func parseBatchRequest(incomingMsg json.RawMessage) ([]rpcRequest, bool, Error)
id := &in[i].Id
// shh_subscribe should not be handled in a special way
if !strings.HasPrefix(r.Method, "shh_") {
// subscribe are special, they will always use `subscriptionMethod` as first param in the payload
if strings.HasSuffix(r.Method, subscribeMethodSuffix) {
requests[i] = rpcRequest{id: id, isPubSub: true}
@ -233,6 +238,7 @@ func parseBatchRequest(incomingMsg json.RawMessage) ([]rpcRequest, bool, Error)
return nil, true, &invalidRequestError{"Unable to parse (un)subscribe request arguments"}
}
}
if strings.HasSuffix(r.Method, unsubscribeMethodSuffix) {
requests[i] = rpcRequest{id: id, isPubSub: true, method: r.Method, params: r.Payload}