# HG changeset patch # User Matthew Wild # Date 1533414744 -3600 # Node ID 6e42ef9c805c46e5951afbef0687d7ce2d2ec152 # Parent e70b9e8bc443e3e89a6a4e8f2061d4e2583ecf64 util.pubsub: Add method to retrieve node configuration diff -r e70b9e8bc443 -r 6e42ef9c805c util/pubsub.lua --- a/util/pubsub.lua Sat Aug 04 21:30:10 2018 +0100 +++ b/util/pubsub.lua Sat Aug 04 21:32:24 2018 +0100 @@ -592,6 +592,27 @@ return true; end +function service:get_node_config(node, actor) + if not self:may(node, actor, "get_configuration") then + return false, "forbidden"; + end + + local node_obj = self.nodes[node]; + if not node_obj then + return false, "item-not-found"; + end + + local config_table = {}; + for k, v in pairs(default_node_config) do + config_table[k] = v; + end + for k, v in pairs(node_obj.config) do + config_table[k] = v; + end + + return true, config_table; +end + return { new = new; };