Software /
code /
prosody
Changeset
1138:0310a0f5ce3a
mod_muc: Extracted history broadcast into its own function
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Fri, 08 May 2009 01:14:01 +0500 |
parents | 1137:4a39a6d503d0 |
children | 1139:ed4d43c3eaf2 |
files | plugins/mod_muc.lua |
diffstat | 1 files changed, 14 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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