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 | 0e2b3ce46897f044dba8a262bb3a7cf848d624be (patch) | |
tree | 8d5edc28dec93034a7e7495848b078f3603e9ac1 /plugins | |
parent | 2e85ac05dddc25aec01225933656982c9a5bcd31 (diff) | |
download | prosody-0e2b3ce46897f044dba8a262bb3a7cf848d624be.tar.gz prosody-0e2b3ce46897f044dba8a262bb3a7cf848d624be.zip |
mod_pubsub, util.pubsub: Support for unsubscribing
Diffstat (limited to 'plugins')
-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"); |