Software /
code /
prosody
Changeset
6450:25d86b0f2147
Merge 0.10->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 28 Sep 2014 03:08:03 +0200 |
parents | 6449:24cd03cd1847 (current diff) 6448:f799b45cf735 (diff) |
children | 6451:385932a83013 |
files | plugins/mod_pubsub/mod_pubsub.lua |
diffstat | 2 files changed, 21 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_pubsub/mod_pubsub.lua Sun Sep 28 03:07:46 2014 +0200 +++ b/plugins/mod_pubsub/mod_pubsub.lua Sun Sep 28 03:08:03 2014 +0200 @@ -218,19 +218,6 @@ }; }; - 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;
--- a/plugins/mod_pubsub/pubsub.lib.lua Sun Sep 28 03:07:46 2014 +0200 +++ b/plugins/mod_pubsub/pubsub.lib.lua Sun Sep 28 03:08:03 2014 +0200 @@ -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 @@ 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"); @@ -230,7 +244,7 @@ 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 @@ -239,15 +253,10 @@ 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 @@ 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 @@ -274,8 +282,8 @@ 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_defaults)); return origin.send(reply); end