Mercurial > prosody-modules
comparison mod_pubsub_text_interface/mod_pubsub_text_interface.lua @ 3248:ecec46f7d020
mod_pubsub_text_interface: Fix chain that accidentally produced nested <body>
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 20 Aug 2018 22:58:30 +0200 |
| parents | ada7a0c7221c |
| children | 8f4a7084c466 |
comparison
equal
deleted
inserted
replaced
| 3247:ada7a0c7221c | 3248:ecec46f7d020 |
|---|---|
| 24 local from = stanza.attr.from; | 24 local from = stanza.attr.from; |
| 25 | 25 |
| 26 local reply = st.reply(stanza); | 26 local reply = st.reply(stanza); |
| 27 reply.attr.id = id.medium(); | 27 reply.attr.id = id.medium(); |
| 28 | 28 |
| 29 local command, node = body:match("^(%a+)%s+(.*)"); | |
| 30 | |
| 29 if body == "help" then | 31 if body == "help" then |
| 30 reply:body(help); | 32 reply:body(help); |
| 31 elseif body == "list" then | 33 elseif body == "list" then |
| 32 local ok, nodes = pubsub:get_nodes(from); | 34 local ok, nodes = pubsub:get_nodes(from); |
| 33 if ok then | 35 if ok then |
| 37 end | 39 end |
| 38 reply:body(table.concat(list, "\n")); | 40 reply:body(table.concat(list, "\n")); |
| 39 else | 41 else |
| 40 reply:body(nodes); | 42 reply:body(nodes); |
| 41 end | 43 end |
| 42 end | 44 elseif command == "subscribe" then |
| 43 local command, node = body:match("^(%a+)%s+(.*)"); | |
| 44 if command == "subscribe" then | |
| 45 local ok, err = pubsub:add_subscription(node, from, jid.bare(from), { ["pubsub#include_body"] = true }); | 45 local ok, err = pubsub:add_subscription(node, from, jid.bare(from), { ["pubsub#include_body"] = true }); |
| 46 reply:body(ok and "OK" or err); | 46 reply:body(ok and "OK" or err); |
| 47 elseif command == "unsubscribe" then | 47 elseif command == "unsubscribe" then |
| 48 local ok, err = pubsub:remove_subscription(node, from, jid.bare(from)); | 48 local ok, err = pubsub:remove_subscription(node, from, jid.bare(from)); |
| 49 reply:body(ok and "OK" or err); | 49 reply:body(ok and "OK" or err); |
