Software /
code /
prosody
Changeset
9107:6e42ef9c805c
util.pubsub: Add method to retrieve node configuration
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 04 Aug 2018 21:32:24 +0100 |
parents | 9106:e70b9e8bc443 |
children | 9108:86f31a2174b3 |
files | util/pubsub.lua |
diffstat | 1 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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; };