Comparison

util/pubsub.lua @ 9075:46d4322f7eed

util.pubsub: Add support for a config validation function
author Matthew Wild <mwild1@gmail.com>
date Wed, 01 Aug 2018 19:18:07 +0100
parent 9031:d1a4b1b78695
child 9095:5639dc1a3f85
comparison
equal deleted inserted replaced
9074:0462405b1cfb 9075:46d4322f7eed
540 local node_obj = self.nodes[node]; 540 local node_obj = self.nodes[node];
541 if not node_obj then 541 if not node_obj then
542 return false, "item-not-found"; 542 return false, "item-not-found";
543 end 543 end
544 544
545 if self.config.check_node_config then
546 local ok = self.config.check_node_config(node, actor, new_config);
547 if not ok then
548 return false, "not-acceptable";
549 end
550 end
551
545 local old_config = node_obj.config; 552 local old_config = node_obj.config;
546 node_obj.config = setmetatable(new_config, {__index=self.node_defaults}); 553 node_obj.config = setmetatable(new_config, {__index=self.node_defaults});
547 554
548 if self.config.nodestore then 555 if self.config.nodestore then
549 local ok, err = save_node_to_store(self, node_obj); 556 local ok, err = save_node_to_store(self, node_obj);