Software /
code /
prosody
Changeset
1139:ed4d43c3eaf2
mod_muc: Extracted sending of occupant list into its own function
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Fri, 08 May 2009 01:27:22 +0500 |
parents | 1138:0310a0f5ce3a |
children | 1140:76bd1bd14234 |
files | plugins/mod_muc.lua |
diffstat | 1 files changed, 16 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_muc.lua Fri May 08 01:14:01 2009 +0500 +++ b/plugins/mod_muc.lua Fri May 08 01:27:22 2009 +0500 @@ -218,6 +218,21 @@ 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 @@ 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);