# HG changeset patch # User Waqas Hussain # Date 1241727241 -18000 # Node ID 0310a0f5ce3a0a0318c5803e969f3a067acd8ce1 # Parent 4a39a6d503d07e87c3c9e054564dfcfd4560456f mod_muc: Extracted history broadcast into its own function diff -r 4a39a6d503d0 -r 0310a0f5ce3a plugins/mod_muc.lua --- a/plugins/mod_muc.lua Fri May 08 01:09:07 2009 +0500 +++ b/plugins/mod_muc.lua Fri May 08 01:14:01 2009 +0500 @@ -205,6 +205,19 @@ end end end +function broadcast_history(room, to) + local history = rooms_info:get(room, 'history'); -- send discussion history + if history then + for _, msg in ipairs(history) do + msg = st.deserialize(msg); + msg.attr.to=to; + core_route_stanza(component, msg); + end + end + if rooms_info:get(room, 'subject') then + core_route_stanza(component, st.message({type='groupchat', from=room, to=to}):tag("subject"):text(rooms_info:get(room, 'subject'))); + end +end function handle_to_occupant(origin, stanza) -- PM, vCards, etc local from, to = stanza.attr.from, stanza.attr.to; @@ -298,17 +311,7 @@ end pr.attr.from = to; broadcast_presence_stanza(room, pr); - local history = rooms_info:get(room, 'history'); -- send discussion history - if history then - for _, msg in ipairs(history) do - msg = st.deserialize(msg); - msg.attr.to=from; - core_route_stanza(component, msg); - end - end - if rooms_info:get(room, 'subject') then - core_route_stanza(component, st.message({type='groupchat', from=room, to=from}):tag("subject"):text(rooms_info:get(room, 'subject'))); - end + broadcast_history(room, from); end end elseif type ~= 'result' then -- bad type