Software /
code /
prosody
Diff
util/pubsub.lua @ 3821:cef2d5dc65e3
mod_pubsub, util.pubsub: Support for unsubscribing
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Sun, 05 Dec 2010 02:46:08 +0100 |
parent | 3796:405231b1cb88 |
child | 3699:150e58d69e60 |
line wrap: on
line diff
--- a/util/pubsub.lua Fri Dec 03 16:36:13 2010 +0100 +++ b/util/pubsub.lua Sun Dec 05 02:46:08 2010 +0100 @@ -17,7 +17,14 @@ end function service:remove_subscription(node, actor, jid) - self.nodes[node].subscribers[jid] = nil; + local node_obj = self.nodes[node]; + if not node_obj then + return false, "item-not-found"; + end + if not node_obj.subscribers[jid] then + return false, "not-subscribed"; + end + node_obj.subscribers[jid] = nil; return true; end