util.pubsub: Check whether node exists, when deleting
[prosody.git] / util / pubsub.lua
index e7fc86b10c23d706b1c6792bcb22eabd74ab3032..e1418c62d51fdccf96b4f8605789ce0378e11a9e 100644 (file)
@@ -233,6 +233,9 @@ function service:delete(node, actor)
        end
        --
        local node_obj = self.nodes[node];
+       if not node_obj then
+               return false, "item-not-found";
+       end
        self.nodes[node] = nil;
        self.config.broadcaster("delete", node, node_obj.subscribers);
        return true;
@@ -350,7 +353,7 @@ function service:get_subscriptions(node, actor, jid)
                        if node then -- Return only subscriptions to this node
                                if subscribed_nodes[node] then
                                        ret[#ret+1] = {
-                                               node = subscribed_nodes[node];
+                                               node = node;
                                                jid = jid;
                                                subscription = node_obj.subscribers[jid];
                                        };