From ae8176a49c9d055e72027dcf44adbe90feb4999b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 6 Aug 2018 17:04:11 +0200 Subject: util.pubsub: Re-check all subscriptions on access_model change, unsubscribing those no longer allowed --- util/pubsub.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/util/pubsub.lua b/util/pubsub.lua index f9255a55..b1aad71f 100644 --- a/util/pubsub.lua +++ b/util/pubsub.lua @@ -598,6 +598,18 @@ function service:set_node_config(node, actor, new_config) end end + if old_config["access_model"] ~= node_obj.config["access_model"] then + for subscriber in pairs(node_obj.subscribers) do + if not self:may(node, subscriber, "be_subscribed") then + local ok, err = self:remove_subscription(node, true, subscriber); + if not ok then + node_obj.config = old_config; + return ok, err; + end + end + end + end + if old_config["persist_items"] ~= node_obj.config["persist_items"] then self.data[node] = self.config.itemstore(self.nodes[node].config, node); elseif old_config["max_items"] ~= node_obj.config["max_items"] then -- cgit v1.2.3