From 45d221ffec158643440974fc200efe4789eea56c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 21 Mar 2018 23:40:45 +0100 Subject: util.pubsub: Allow setting a callback for validating items to be published --- util/pubsub.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'util') 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 -- cgit v1.2.3