From 684562c67d0344ef797301763685c671a6f3ef2b Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Fri, 8 May 2009 01:14:01 +0500 Subject: mod_muc: Extracted history broadcast into its own function --- plugins/mod_muc.lua | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/plugins/mod_muc.lua b/plugins/mod_muc.lua index ffa0bb85..c07102c9 100644 --- a/plugins/mod_muc.lua +++ b/plugins/mod_muc.lua @@ -205,6 +205,19 @@ function broadcast_presence_stanza(room, stanza, code, nick) 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 @@ function handle_to_occupant(origin, stanza) -- PM, vCards, etc 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 -- cgit v1.2.3