Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
8693:6e24a69b03af | 8694:059183e5571e |
---|---|
4 local service_mt = {}; | 4 local service_mt = {}; |
5 | 5 |
6 local default_config = { | 6 local default_config = { |
7 itemstore = function (config, _) return cache.new(config["max_items"]) end; | 7 itemstore = function (config, _) return cache.new(config["max_items"]) end; |
8 broadcaster = function () end; | 8 broadcaster = function () end; |
9 itemcheck = function () return true; end; | |
9 get_affiliation = function () end; | 10 get_affiliation = function () end; |
10 capabilities = {}; | 11 capabilities = {}; |
11 }; | 12 }; |
12 local default_config_mt = { __index = default_config }; | 13 local default_config_mt = { __index = default_config }; |
13 | 14 |
303 local ok, err = self:create(node, true); | 304 local ok, err = self:create(node, true); |
304 if not ok then | 305 if not ok then |
305 return ok, err; | 306 return ok, err; |
306 end | 307 end |
307 node_obj = self.nodes[node]; | 308 node_obj = self.nodes[node]; |
309 end | |
310 if not self.config.itemcheck(item) then | |
311 return nil, "internal-server-error"; | |
308 end | 312 end |
309 local node_data = self.data[node]; | 313 local node_data = self.data[node]; |
310 local ok = node_data:set(id, item); | 314 local ok = node_data:set(id, item); |
311 if not ok then | 315 if not ok then |
312 return nil, "internal-server-error"; | 316 return nil, "internal-server-error"; |