Comparison

plugins/mod_pubsub/pubsub.lib.lua @ 8980:4d2738b99b07

mod_pubsub: Move service discovery to pubsub.lib to allow reuse
author Kim Alvefur <zash@zash.se>
date Fri, 06 Jul 2018 18:00:50 +0200
parent 8979:6897b2e18bdf
child 8981:b6cb0a8f75b1
comparison
equal deleted inserted replaced
8979:6897b2e18bdf 8980:4d2738b99b07
136 end 136 end
137 137
138 return supported_features; 138 return supported_features;
139 end 139 end
140 140
141 function _M.handle_disco_info_node(event, service)
142 local stanza, reply, node = event.stanza, event.reply, event.node;
143 local ok, ret = service:get_nodes(stanza.attr.from);
144 local node_obj = ret[node];
145 if not ok or not node_obj then
146 return;
147 end
148 event.exists = true;
149 reply:tag("identity", { category = "pubsub", type = "leaf" }):up();
150 end
151
152 function _M.handle_disco_items_node(event, service)
153 local stanza, reply, node = event.stanza, event.reply, event.node;
154 local ok, ret = service:get_items(node, stanza.attr.from);
155 if not ok then
156 return;
157 end
158
159 for _, id in ipairs(ret) do
160 reply:tag("item", { jid = module.host, name = id }):up();
161 end
162 event.exists = true;
163 end
164
141 function _M.handle_pubsub_iq(event, service) 165 function _M.handle_pubsub_iq(event, service)
142 local origin, stanza = event.origin, event.stanza; 166 local origin, stanza = event.origin, event.stanza;
143 local pubsub_tag = stanza.tags[1]; 167 local pubsub_tag = stanza.tags[1];
144 local action = pubsub_tag.tags[1]; 168 local action = pubsub_tag.tags[1];
145 if not action then 169 if not action then