Comparison

plugins/mod_pubsub/mod_pubsub.lua @ 5973:905b4fd863b4

Merge 0.10->trunk and Happy New Year!
author Kim Alvefur <zash@zash.se>
date Tue, 31 Dec 2013 19:09:34 +0100
parent 5851:cdcfd93e2f43
parent 5970:6a2c3293d4d7
child 6442:0f4025abbe8f
comparison
equal deleted inserted replaced
5967:3b7206981317 5973:905b4fd863b4
84 end 84 end
85 85
86 module:hook("host-disco-info-node", function (event) 86 module:hook("host-disco-info-node", function (event)
87 local stanza, origin, reply, node = event.stanza, event.origin, event.reply, event.node; 87 local stanza, origin, reply, node = event.stanza, event.origin, event.reply, event.node;
88 local ok, ret = service:get_nodes(stanza.attr.from); 88 local ok, ret = service:get_nodes(stanza.attr.from);
89 if ok and not ret[node] then 89 if not ok or not ret[node] then
90 return; 90 return;
91 end
92 if not ok then
93 return origin.send(pubsub_error_reply(stanza, ret));
94 end 91 end
95 event.exists = true; 92 event.exists = true;
96 reply:tag("identity", { category = "pubsub", type = "leaf" }); 93 reply:tag("identity", { category = "pubsub", type = "leaf" });
97 end); 94 end);
98 95
99 module:hook("host-disco-items-node", function (event) 96 module:hook("host-disco-items-node", function (event)
100 local stanza, origin, reply, node = event.stanza, event.origin, event.reply, event.node; 97 local stanza, origin, reply, node = event.stanza, event.origin, event.reply, event.node;
101 local ok, ret = service:get_items(node, stanza.attr.from); 98 local ok, ret = service:get_items(node, stanza.attr.from);
102 if not ok then 99 if not ok then
103 return origin.send(pubsub_error_reply(stanza, ret)); 100 return;
104 end 101 end
105 102
106 for _, id in ipairs(ret) do 103 for _, id in ipairs(ret) do
107 reply:tag("item", { jid = module.host, name = id }):up(); 104 reply:tag("item", { jid = module.host, name = id }):up();
108 end 105 end
112 109
113 module:hook("host-disco-items", function (event) 110 module:hook("host-disco-items", function (event)
114 local stanza, origin, reply = event.stanza, event.origin, event.reply; 111 local stanza, origin, reply = event.stanza, event.origin, event.reply;
115 local ok, ret = service:get_nodes(event.stanza.attr.from); 112 local ok, ret = service:get_nodes(event.stanza.attr.from);
116 if not ok then 113 if not ok then
117 return origin.send(pubsub_error_reply(event.stanza, ret)); 114 return;
118 end 115 end
119 for node, node_obj in pairs(ret) do 116 for node, node_obj in pairs(ret) do
120 reply:tag("item", { jid = module.host, node = node, name = node_obj.config.name }):up(); 117 reply:tag("item", { jid = module.host, node = node, name = node_obj.config.name }):up();
121 end 118 end
122 end); 119 end);