aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-08-06 11:23:09 +0100
committerMatthew Wild <mwild1@gmail.com>2018-08-06 11:23:09 +0100
commit33a2c854019f717a0d88c129983ce0f67f10ce4b (patch)
tree2fbcdc5621929bff9dd54c49aaff5006fc82bdc4 /util
parent8fd069d330babf6eef75aa841f5241f5fef193e0 (diff)
downloadprosody-33a2c854019f717a0d88c129983ce0f67f10ce4b.tar.gz
prosody-33a2c854019f717a0d88c129983ce0f67f10ce4b.zip
util.pubsub: Add support for publish_model config option
Diffstat (limited to 'util')
-rw-r--r--util/pubsub.lua15
1 files changed, 14 insertions, 1 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua
index 964b26c7..f9255a55 100644
--- a/util/pubsub.lua
+++ b/util/pubsub.lua
@@ -17,6 +17,7 @@ local default_node_config = {
["persist_items"] = false;
["max_items"] = 20;
["access_model"] = "open";
+ ["publish_model"] = "publishers";
};
local default_node_config_mt = { __index = default_node_config };
@@ -365,7 +366,19 @@ end
function service:publish(node, actor, id, item)
-- Access checking
- if not self:may(node, actor, "publish") then
+ local may_publish = false;
+
+ if self:may(node, actor, "publish") then
+ may_publish = true;
+ else
+ local node_obj = self.nodes[node];
+ local publish_model = node_obj and node_obj.config.publish_model;
+ if publish_model == "open"
+ or (publish_model == "subscribers" and node_obj.subscribers[actor]) then
+ may_publish = true;
+ end
+ end
+ if not may_publish then
return false, "forbidden";
end
--