From d37f18c321d98184d89dcb65e1eb40508c83008c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 28 Sep 2014 02:41:13 +0200 Subject: pubsub.lib: Fix actor in configure --- plugins/mod_pubsub/pubsub.lib.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index 8a22fa69..3ed72fec 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -230,7 +230,7 @@ function handlers.get_configure(origin, stanza, config, service) return origin.send(pubsub_error_reply(stanza, "nodeid-required")); end - if not service:may(node, actor, "configure") then + if not service:may(node, stanza.attr.from, "configure") then return origin.send(pubsub_error_reply(stanza, "forbidden")); end -- cgit v1.2.3 From c9fece7b7edaa98b186e3e9c2d883935d3855ef9 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 28 Sep 2014 02:47:54 +0200 Subject: mod_pubsub: Move node config form into pubsub.lib (Thanks Florob) --- plugins/mod_pubsub/mod_pubsub.lua | 13 ------------- plugins/mod_pubsub/pubsub.lib.lua | 28 ++++++++++++++++++---------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua index 0ffa7981..8c777f54 100644 --- a/plugins/mod_pubsub/mod_pubsub.lua +++ b/plugins/mod_pubsub/mod_pubsub.lua @@ -218,19 +218,6 @@ function module.load() }; }; - node_config_form = require"util.dataforms".new { - { - type = "hidden"; - name = "FORM_TYPE"; - value = "http://jabber.org/protocol/pubsub#node_config"; - }; - { - type = "text-single"; - name = "pubsub#max_items"; - label = "Max # of items to persist"; - }; - }; - autocreate_on_publish = autocreate_on_publish; autocreate_on_subscribe = autocreate_on_subscribe; diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index 3ed72fec..9d8a5c60 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -1,5 +1,6 @@ local st = require "util.stanza"; local uuid_generate = require "util.uuid".generate; +local dataform = require"util.dataforms".new; local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; local xmlns_pubsub_errors = "http://jabber.org/protocol/pubsub#errors"; @@ -30,6 +31,19 @@ local function pubsub_error_reply(stanza, error) end _M.pubsub_error_reply = pubsub_error_reply; +local node_config_form = require"util.dataforms".new { + { + type = "hidden"; + name = "FORM_TYPE"; + value = "http://jabber.org/protocol/pubsub#node_config"; + }; + { + type = "text-single"; + name = "pubsub#max_items"; + label = "Max # of items to persist"; + }; +}; + function handlers.get_items(origin, stanza, items, service) local node = items.attr.node; local item = items:get_child("item"); @@ -239,15 +253,10 @@ function handlers.get_configure(origin, stanza, config, service) return origin.send(pubsub_error_reply(stanza, "item-not-found")); end - local form = self.config.node_config_form; - if not form then - return origin.send(pubsub_error_reply(stanza, "not-allowed")); - end - local reply = st.reply(stanza) :tag("pubsub", { xmlns = xmlns_pubsub_owner }) :tag("configure", { node = node }) - :add_child(form:form(node_obj.config)); + :add_child(node_config_form:form(node_obj.config)); return origin.send(reply); end @@ -256,11 +265,10 @@ function handlers.set_configure(origin, stanza, config, service) if not node then return origin.send(pubsub_error_reply(stanza, "nodeid-required")); end - local form, node_obj = service:get_node_config_form(node, stanza.attr.from); - if not form then - return origin.send(pubsub_error_reply(stanza, node_obj)); + if not service:may(node, stanza.attr.from, "configure") then + return origin.send(pubsub_error_reply(stanza, "forbidden")); end - local new_config, err = form:data(config.tags[1]); + local new_config, err = node_config_form:data(config.tags[1]); if not new_config then return origin.send(st.error_reply(stanza, "modify", "bad-request", err)); end -- cgit v1.2.3 From 3f3816afda3c521f31dd54f24e4191d49bb72a1f Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 28 Sep 2014 02:48:29 +0200 Subject: mod_pubsub: Fix retreival of node config defaults --- plugins/mod_pubsub/pubsub.lib.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index 9d8a5c60..b74c90a7 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -282,8 +282,8 @@ end function handlers.get_default(origin, stanza, default, service) local reply = st.reply(stanza) :tag("pubsub", { xmlns = xmlns_pubsub_owner }) - :tag("configure", { node = node }) - :add_child(form:form(service.node_default_config)); + :tag("default") + :add_child(node_config_form:form(service.node_default_config)); return origin.send(reply); end -- cgit v1.2.3 From 65b12619a33a83952023bd802bc89a3bec929455 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 28 Sep 2014 03:06:29 +0200 Subject: pubsub.lib: Fix variable renaming issue --- plugins/mod_pubsub/pubsub.lib.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index b74c90a7..5c6054d1 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -283,7 +283,7 @@ function handlers.get_default(origin, stanza, default, service) local reply = st.reply(stanza) :tag("pubsub", { xmlns = xmlns_pubsub_owner }) :tag("default") - :add_child(node_config_form:form(service.node_default_config)); + :add_child(node_config_form:form(service.node_defaults)); return origin.send(reply); end -- cgit v1.2.3