Skip to content

Commit

Permalink
keep original subscription negating logic to pass test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
seeLuck committed May 29, 2019
1 parent 9d3d9b1 commit 17c70ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,12 @@ instance.authorizeSubscribe = function (client, sub, callback) {
}
```

To negate a subscription, set the subscription's QoS to `128`:
To negate a subscription, set the subscription to `null`:

```js
instance.authorizeSubscribe = function (client, sub, callback) {
if (sub.topic === 'aaaa') {
sub.qos = 128
sub = null
}

callback(null, sub)
Expand Down
5 changes: 5 additions & 0 deletions lib/handlers/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ function storeSubscriptions (sub, done) {
var broker = client.broker
var perst = broker.persistence

if (!sub) {
this.granted.push(128)
return done(null, sub)
}

if (packet.subscriptions.length > 0 && ++this.subsIndex !== packet.subscriptions.length) {
// TODO change aedes subscribe handle, but this fix bugs for now.
return done(null, sub)
Expand Down

0 comments on commit 17c70ef

Please sign in to comment.