diff options
Diffstat (limited to 'plugins/mod_muc.lua')
-rw-r--r-- | plugins/mod_muc.lua | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/plugins/mod_muc.lua b/plugins/mod_muc.lua index c07102c9..f11cb7e3 100644 --- a/plugins/mod_muc.lua +++ b/plugins/mod_muc.lua @@ -218,6 +218,21 @@ function broadcast_history(room, to) core_route_stanza(component, st.message({type='groupchat', from=room, to=to}):tag("subject"):text(rooms_info:get(room, 'subject'))); end end +function send_occupant_list(room, to) + local r = rooms:get(room); + if r then + local current_nick = jid_nick:get(to, room); + for occupant, o_data in pairs(r) do + if occupant ~= current_nick then + local pres = get_filtered_presence(o_data.sessions[o_data.jid]); + pres.attr.to, pres.attr.from = to, occupant; + pres:tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) + :tag("item", {affiliation=o_data.affiliation, role=o_data.role}):up(); + core_route_stanza(component, pres); + end + end + end +end function handle_to_occupant(origin, stanza) -- PM, vCards, etc local from, to = stanza.attr.from, stanza.attr.to; @@ -297,18 +312,7 @@ function handle_to_occupant(origin, stanza) -- PM, vCards, etc end rooms:set(room, to, data); jid_nick:set(from, room, to); - local r = rooms:get(room); - if r then - for occupant, o_data in pairs(r) do - if occupant ~= to then - local pres = get_filtered_presence(o_data.sessions[o_data.jid]); - pres.attr.to, pres.attr.from = from, occupant; - pres:tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) - :tag("item", {affiliation=o_data.affiliation, role=o_data.role}):up(); - core_route_stanza(component, pres); - end - end - end + send_occupant_list(room, from); pr.attr.from = to; broadcast_presence_stanza(room, pr); broadcast_history(room, from); |