aboutsummaryrefslogtreecommitdiffstats
path: root/util
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
commit3096a0770cd5d4d7fe057260e49ecdbc4f738ab1 (patch)
tree3601fb6a39a2571cb200f67917cf2908f0f1264a /util
parentf7db87ef3ceb32356574d457e693be7435b1b8aa (diff)
downloadprosody-3096a0770cd5d4d7fe057260e49ecdbc4f738ab1.tar.gz
prosody-3096a0770cd5d4d7fe057260e49ecdbc4f738ab1.zip
util.pubsub: Allow setting a callback for validating items to be published
Diffstat (limited to 'util')
-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