aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-10-18 09:08:16 +0200
committerKim Alvefur <zash@zash.se>2017-10-18 09:08:16 +0200
commitc4c07e032b10b4a4b6ccde743508b973fb1891bc (patch)
treeb95b220ac0dc7133123d79d35eba5e303016251e
parent721c4e86bafdbf92a1c89f45ac4eb8c0d2bad744 (diff)
downloadprosody-c4c07e032b10b4a4b6ccde743508b973fb1891bc.tar.gz
prosody-c4c07e032b10b4a4b6ccde743508b973fb1891bc.zip
mod_pubsub: Add support for Create and Configure
-rw-r--r--plugins/mod_pubsub/mod_pubsub.lua2
-rw-r--r--plugins/mod_pubsub/pubsub.lib.lua22
2 files changed, 21 insertions, 3 deletions
diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua
index eccb82d0..4f835ac2 100644
--- a/plugins/mod_pubsub/mod_pubsub.lua
+++ b/plugins/mod_pubsub/mod_pubsub.lua
@@ -62,7 +62,7 @@ module:hook("iq/host/"..xmlns_pubsub..":pubsub", handle_pubsub_iq);
module:hook("iq/host/"..xmlns_pubsub_owner..":pubsub", handle_pubsub_iq);
local feature_map = {
- create = { "create-nodes", "instant-nodes", "item-ids" };
+ create = { "create-nodes", "instant-nodes", "item-ids", "create-and-configure" };
retract = { "delete-items", "retract-items" };
purge = { "purge-nodes" };
publish = { "publish", autocreate_on_publish and "auto-create" };
diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua
index e9801e89..49274601 100644
--- a/plugins/mod_pubsub/pubsub.lib.lua
+++ b/plugins/mod_pubsub/pubsub.lib.lua
@@ -122,8 +122,26 @@ end
function handlers.set_create(origin, stanza, create, service)
local node = create.attr.node;
local ok, ret, reply;
+ local config;
+ local configure = stanza.tags[1]:get_child("configure");
+ if configure then
+ local config_form = config:get_child("x", "jabber:x:data");
+ if not config_form then
+ origin.send(st.error_reply(stanza, "modify", "bad-request", "Missing dataform"));
+ return true;
+ end
+ local form_data, err = node_config_form:data(config_form);
+ if not form_data then
+ origin.send(st.error_reply(stanza, "modify", "bad-request", err));
+ return true;
+ end
+ config = {
+ ["max_items"] = tonumber(form_data["pubsub#max_items"]);
+ ["persist_items"] = form_data["pubsub#persist_items"];
+ };
+ end
if node then
- ok, ret = service:create(node, stanza.attr.from);
+ ok, ret = service:create(node, stanza.attr.from, config);
if ok then
reply = st.reply(stanza);
else
@@ -132,7 +150,7 @@ function handlers.set_create(origin, stanza, create, service)
else
repeat
node = uuid_generate();
- ok, ret = service:create(node, stanza.attr.from);
+ ok, ret = service:create(node, stanza.attr.from, config);
until ok or ret ~= "conflict";
if ok then
reply = st.reply(stanza)