Comparison

util/pubsub.lua @ 3698:77171fd1dc3c

mod_pubsub, util.pubsub: Support for unsubscribing
author Florian Zeitz <florob@babelmonkeys.de>
date Sun, 05 Dec 2010 02:46:08 +0100
parent 3672:b24db47995ac
child 3699:150e58d69e60
comparison
equal deleted inserted replaced
3697:67c01f75af97 3698:77171fd1dc3c
15 node_obj.subscribers[jid] = true; 15 node_obj.subscribers[jid] = true;
16 return true; 16 return true;
17 end 17 end
18 18
19 function service:remove_subscription(node, actor, jid) 19 function service:remove_subscription(node, actor, jid)
20 self.nodes[node].subscribers[jid] = nil; 20 local node_obj = self.nodes[node];
21 if not node_obj then
22 return false, "item-not-found";
23 end
24 if not node_obj.subscribers[jid] then
25 return false, "not-subscribed";
26 end
27 node_obj.subscribers[jid] = nil;
21 return true; 28 return true;
22 end 29 end
23 30
24 function service:get_subscription(node, actor, jid) 31 function service:get_subscription(node, actor, jid)
25 local node_obj = self.nodes[node]; 32 local node_obj = self.nodes[node];