diff options
author | Florian Zeitz <florob@babelmonkeys.de> | 2010-12-05 02:46:08 +0100 |
---|---|---|
committer | Florian Zeitz <florob@babelmonkeys.de> | 2010-12-05 02:46:08 +0100 |
commit | 95db0579ab3d60f61d51a30e5a6535194d3cc8a3 (patch) | |
tree | 1706275ec482e6288106e9f22f49d93f9e109432 /plugins/mod_pubsub.lua | |
parent | 3dce149c8b1eaafc7ec2a5ff8e263bc30a36bfe0 (diff) | |
download | prosody-95db0579ab3d60f61d51a30e5a6535194d3cc8a3.tar.gz prosody-95db0579ab3d60f61d51a30e5a6535194d3cc8a3.zip |
mod_pubsub, util.pubsub: Support for unsubscribing
Diffstat (limited to 'plugins/mod_pubsub.lua')
-rw-r--r-- | plugins/mod_pubsub.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 83ce0ad9..0475ea1d 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -28,6 +28,7 @@ local pubsub_errors = { ["conflict"] = { "cancel", "conflict" }; ["invalid-jid"] = { "modify", "bad-request", nil, "invalid-jid" }; ["item-not-found"] = { "cancel", "item-not-found" }; + ["not-subscribed"] = { "modify", "unexpected-request", nil, "not-subscribed" }; }; function pubsub_error_reply(stanza, error) local e = pubsub_errors[error]; @@ -99,6 +100,21 @@ function handlers.set_subscribe(origin, stanza, subscribe) return origin.send(reply); end +function handlers.set_unsubscribe(origin, stanza, unsubscribe) + local node, jid = unsubscribe.attr.node, unsubscribe.attr.jid; + if jid_bare(jid) ~= jid_bare(stanza.attr.from) then + return origin.send(pubsub_error_reply(stanza, "invalid-jid")); + end + local ok, ret = service:remove_subscription(node, stanza.attr.from, jid); + local reply; + if ok then + reply = st.reply(stanza); + else + reply = pubsub_error_reply(stanza, ret); + end + return origin.send(reply); +end + function handlers.set_publish(origin, stanza, publish) local node = publish.attr.node; local item = publish:get_child("item"); |