diff options
author | Florian Zeitz <florob@babelmonkeys.de> | 2010-12-01 23:38:47 +0100 |
---|---|---|
committer | Florian Zeitz <florob@babelmonkeys.de> | 2010-12-01 23:38:47 +0100 |
commit | 39939bd65e46a352137193bb01352b0b2e445727 (patch) | |
tree | bb9ce1baef66c09123e8c3b95067140b315af805 /plugins/mod_pubsub.lua | |
parent | 8622eff8323d762364c9c48d5b1187263685821f (diff) | |
download | prosody-39939bd65e46a352137193bb01352b0b2e445727.tar.gz prosody-39939bd65e46a352137193bb01352b0b2e445727.zip |
mod_pubsub, util.pubsub: Support node creation
Diffstat (limited to 'plugins/mod_pubsub.lua')
-rw-r--r-- | plugins/mod_pubsub.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index da2070f3..f92d27aa 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -55,6 +55,28 @@ function handlers.get_items(origin, stanza, items) return origin.send(reply); end +function handlers.set_create(origin, stanza, create) + local node = create.attr.node; + local ok, ret, reply; + if node then + ok, ret = service:create(node, stanza.attr.from); + if ok then + reply = st.reply(stanza); + else + reply = st.error_reply(stanza, "cancel", ret); + end + else + repeat + node = uuid_generate(); + ok, ret = service:create(node, stanza.attr.from); + until ok; + reply = st.reply(stanza) + :tag("pubsub", { xmlns = xmlns_pubsub }) + :tag("create", { node = node }); + end + origin.send(reply); +end + function handlers.set_subscribe(origin, stanza, subscribe) local node, jid = subscribe.attr.node, subscribe.attr.jid; if jid_bare(jid) ~= jid_bare(stanza.attr.from) then |