diff options
author | Waqas Hussain <waqas20@gmail.com> | 2009-05-08 01:14:01 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2009-05-08 01:14:01 +0500 |
commit | 684562c67d0344ef797301763685c671a6f3ef2b (patch) | |
tree | d3d65c452138a9567208dbe72dcbe255dadfc18c /plugins | |
parent | 27db90c5514bfdf0c4ff98bb201d25e8a5e291a3 (diff) | |
download | prosody-684562c67d0344ef797301763685c671a6f3ef2b.tar.gz prosody-684562c67d0344ef797301763685c671a6f3ef2b.zip |
mod_muc: Extracted history broadcast into its own function
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_muc.lua | 25 |
1 files 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 |