Mercurial > prosody-hg
comparison plugins/mod_pubsub.lua @ 3672:b24db47995ac
mod_pubsub, util.pubsub: Support node creation
| author | Florian Zeitz <florob@babelmonkeys.de> |
|---|---|
| date | Wed, 01 Dec 2010 23:38:47 +0100 |
| parents | 3603aeb325de |
| children | 67c01f75af97 |
comparison
equal
deleted
inserted
replaced
| 3671:b7d5fe8eb829 | 3672:b24db47995ac |
|---|---|
| 51 :add_child(data); | 51 :add_child(data); |
| 52 else | 52 else |
| 53 reply = st.error_reply(stanza, "cancel", "item-not-found", "Item could not be found in this node"); | 53 reply = st.error_reply(stanza, "cancel", "item-not-found", "Item could not be found in this node"); |
| 54 end | 54 end |
| 55 return origin.send(reply); | 55 return origin.send(reply); |
| 56 end | |
| 57 | |
| 58 function handlers.set_create(origin, stanza, create) | |
| 59 local node = create.attr.node; | |
| 60 local ok, ret, reply; | |
| 61 if node then | |
| 62 ok, ret = service:create(node, stanza.attr.from); | |
| 63 if ok then | |
| 64 reply = st.reply(stanza); | |
| 65 else | |
| 66 reply = st.error_reply(stanza, "cancel", ret); | |
| 67 end | |
| 68 else | |
| 69 repeat | |
| 70 node = uuid_generate(); | |
| 71 ok, ret = service:create(node, stanza.attr.from); | |
| 72 until ok; | |
| 73 reply = st.reply(stanza) | |
| 74 :tag("pubsub", { xmlns = xmlns_pubsub }) | |
| 75 :tag("create", { node = node }); | |
| 76 end | |
| 77 origin.send(reply); | |
| 56 end | 78 end |
| 57 | 79 |
| 58 function handlers.set_subscribe(origin, stanza, subscribe) | 80 function handlers.set_subscribe(origin, stanza, subscribe) |
| 59 local node, jid = subscribe.attr.node, subscribe.attr.jid; | 81 local node, jid = subscribe.attr.node, subscribe.attr.jid; |
| 60 if jid_bare(jid) ~= jid_bare(stanza.attr.from) then | 82 if jid_bare(jid) ~= jid_bare(stanza.attr.from) then |
