Software /
code /
prosody
Diff
util/pubsub.lua @ 8694:059183e5571e
util.pubsub: Allow setting a callback for validating items to be published
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 21 Mar 2018 23:40:45 +0100 |
parent | 8502:6c2c2fc4b8dd |
child | 8809:6cba2df3817c |
line wrap: on
line diff
--- a/util/pubsub.lua Sun Mar 25 17:02:39 2018 +0200 +++ b/util/pubsub.lua Wed Mar 21 23:40:45 2018 +0100 @@ -6,6 +6,7 @@ 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 @@ 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