From 17c70efd6f2c4eee1a1be541719dd99196b57c28 Mon Sep 17 00:00:00 2001 From: seeLuck <810201584@qq.com> Date: Wed, 29 May 2019 20:54:15 +0800 Subject: [PATCH] keep original subscription negating logic to pass test case. --- README.md | 4 ++-- lib/handlers/subscribe.js | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f37e809e..98518822 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/lib/handlers/subscribe.js b/lib/handlers/subscribe.js index 82073419..ed90a317 100644 --- a/lib/handlers/subscribe.js +++ b/lib/handlers/subscribe.js @@ -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)