Comparison

plugins/muc/muc.lib.lua @ 9238:0c1a1172d942

MUC: Add support for separate events for disco#info queries with a 'node' Reserved nickname discovery uses this
author Matthew Wild <mwild1@gmail.com>
date Mon, 03 Sep 2018 12:19:20 +0100
parent 9237:b86c2e135797
child 9239:03e37f7d6c97
comparison
equal deleted inserted replaced
9237:b86c2e135797 9238:0c1a1172d942
332 end 332 end
333 end 333 end
334 end 334 end
335 335
336 function room_mt:get_disco_info(stanza) 336 function room_mt:get_disco_info(stanza)
337 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#info"); 337 local node = stanza.tags[1].attr.node or "";
338 local form = dataform.new { 338 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#info", { node = node });
339 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/muc#roominfo" }; 339 local event_name = "muc-disco#info";
340 }; 340 local event_data = { room = self, reply = reply, stanza = stanza };
341 local formdata = {}; 341
342 module:fire_event("muc-disco#info", {room = self; reply = reply; form = form, formdata = formdata ;}); 342 if node ~= "" then
343 reply:add_child(form:form(formdata, "result")); 343 event_name = event_name.."/"..node;
344 else
345 event_data.form = dataform.new {
346 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/muc#roominfo" };
347 };
348 event_data.formdata = {};
349 end
350 module:fire_event(event_name, event_data);
351 if event_data.form then
352 reply:add_child(event_data.form:form(event_data.formdata, "result"));
353 end
344 return reply; 354 return reply;
345 end 355 end
346 module:hook("muc-disco#info", function(event) 356 module:hook("muc-disco#info", function(event)
347 event.reply:tag("feature", {var = "http://jabber.org/protocol/muc"}):up(); 357 event.reply:tag("feature", {var = "http://jabber.org/protocol/muc"}):up();
348 event.reply:tag("feature", {var = "http://jabber.org/protocol/muc#stable_id"}):up(); 358 event.reply:tag("feature", {var = "http://jabber.org/protocol/muc#stable_id"}):up();