diff options
author | Waqas Hussain <waqas20@gmail.com> | 2009-05-08 01:27:22 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2009-05-08 01:27:22 +0500 |
commit | a747c4ddf2ebe01d5307a7668601524ab7b7fddb (patch) | |
tree | 1d68ce218e642d550748505bd8a7cea4fa2d5990 /plugins/mod_muc.lua | |
parent | 684562c67d0344ef797301763685c671a6f3ef2b (diff) | |
download | prosody-a747c4ddf2ebe01d5307a7668601524ab7b7fddb.tar.gz prosody-a747c4ddf2ebe01d5307a7668601524ab7b7fddb.zip |
mod_muc: Extracted sending of occupant list into its own function
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); |