aboutsummaryrefslogtreecommitdiffstats
path: root/util/pubsub.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-03-21 23:40:45 +0100
committerKim Alvefur <zash@zash.se>2018-03-21 23:40:45 +0100
commit45d221ffec158643440974fc200efe4789eea56c (patch)
tree3601fb6a39a2571cb200f67917cf2908f0f1264a /util/pubsub.lua
parent6684c9901af17e078bdfef3dda93ba4cd0909bff (diff)
downloadprosody-45d221ffec158643440974fc200efe4789eea56c.tar.gz
prosody-45d221ffec158643440974fc200efe4789eea56c.zip
util.pubsub: Allow setting a callback for validating items to be published
Diffstat (limited to 'util/pubsub.lua')
-rw-r--r--util/pubsub.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua
index 0370bae2..3a00aae5 100644
--- a/util/pubsub.lua
+++ b/util/pubsub.lua
@@ -6,6 +6,7 @@ local service_mt = {};
local default_config = {
itemstore = function (config, _) return cache.new(config["max_items"]) end;
broadcaster = function () end;
+ itemcheck = function () return true; end;
get_affiliation = function () end;
capabilities = {};
};
@@ -306,6 +307,9 @@ function service:publish(node, actor, id, item)
end
node_obj = self.nodes[node];
end
+ if not self.config.itemcheck(item) then
+ return nil, "internal-server-error";
+ end
local node_data = self.data[node];
local ok = node_data:set(id, item);
if not ok then