Comparison

plugins/muc/muc.lib.lua @ 13560:ccf389f54a93

Merge 0.12->trunk
author Matthew Wild <mwild1@gmail.com>
date Fri, 15 Nov 2024 14:37:10 +0000
parent 13415:f34b33cb1383
parent 13559:eedae7d47784
comparison
equal deleted inserted replaced
13558:56e112b890ea 13560:ccf389f54a93
302 302
303 local broadcast_roles = self:get_presence_broadcast(); 303 local broadcast_roles = self:get_presence_broadcast();
304 -- General populace 304 -- General populace
305 for occupant_nick, n_occupant in self:each_occupant() do 305 for occupant_nick, n_occupant in self:each_occupant() do
306 if occupant_nick ~= occupant.nick then 306 if occupant_nick ~= occupant.nick then
307 local pr = get_p(n_occupant);
308 if broadcast_roles[occupant.role or "none"] or force_unavailable then 307 if broadcast_roles[occupant.role or "none"] or force_unavailable then
309 self:route_to_occupant(n_occupant, pr); 308 self:route_to_occupant(n_occupant, get_p(n_occupant));
310 elseif prev_role and broadcast_roles[prev_role] then 309 elseif prev_role and broadcast_roles[prev_role] then
310 local pr = get_p(n_occupant);
311 pr.attr.type = 'unavailable'; 311 pr.attr.type = 'unavailable';
312 self:route_to_occupant(n_occupant, pr); 312 self:route_to_occupant(n_occupant, pr);
313 end 313 end
314 314
315 end 315 end
337 local broadcast_roles = self:get_presence_broadcast(); 337 local broadcast_roles = self:get_presence_broadcast();
338 local is_anonymous = self:is_anonymous_for(to); 338 local is_anonymous = self:is_anonymous_for(to);
339 local broadcast_bare_jids = {}; -- Track which bare JIDs we have sent presence for 339 local broadcast_bare_jids = {}; -- Track which bare JIDs we have sent presence for
340 for occupant_jid, occupant in self:each_occupant() do 340 for occupant_jid, occupant in self:each_occupant() do
341 broadcast_bare_jids[occupant.bare_jid] = true; 341 broadcast_bare_jids[occupant.bare_jid] = true;
342 if filter == nil or filter(occupant_jid, occupant) then 342 if (filter == nil or filter(occupant_jid, occupant)) and (to_bare == occupant.bare_jid or broadcast_roles[occupant.role or "none"]) then
343 local x = st.stanza("x", {xmlns='http://jabber.org/protocol/muc#user'}); 343 local x = st.stanza("x", {xmlns='http://jabber.org/protocol/muc#user'});
344 self:build_item_list(occupant, x, is_anonymous and to_bare ~= occupant.bare_jid); -- can always see your own jids 344 self:build_item_list(occupant, x, is_anonymous and to_bare ~= occupant.bare_jid); -- can always see your own jids
345 local pres = st.clone(occupant:get_presence()); 345 local pres = st.clone(occupant:get_presence());
346 pres.attr.to = to; 346 pres.attr.to = to;
347 pres:add_child(x); 347 pres:add_child(x);
348 module:fire_event("muc-build-occupant-presence", { room = self, occupant = occupant, stanza = pres }); 348 module:fire_event("muc-build-occupant-presence", { room = self, occupant = occupant, stanza = pres });
349 if to_bare == occupant.bare_jid or broadcast_roles[occupant.role or "none"] then 349 self:route_stanza(pres);
350 self:route_stanza(pres);
351 end
352 end 350 end
353 end 351 end
354 if broadcast_roles.none then 352 if broadcast_roles.none then
355 -- Broadcast stanzas for affiliated users not currently in the MUC 353 -- Broadcast stanzas for affiliated users not currently in the MUC
356 for affiliated_jid, affiliation, affiliation_data in self:each_affiliation() do 354 for affiliated_jid, affiliation, affiliation_data in self:each_affiliation() do