Mercurial > prosody-hg
comparison plugins/mod_muc.lua @ 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 | 0cb325970a50 |
| children | ed4d43c3eaf2 |
comparison
equal
deleted
inserted
replaced
| 1137:4a39a6d503d0 | 1138:0310a0f5ce3a |
|---|---|
| 201 stanza:tag("status", {code='110'}); | 201 stanza:tag("status", {code='110'}); |
| 202 for jid in pairs(me.sessions) do | 202 for jid in pairs(me.sessions) do |
| 203 stanza.attr.to = jid; | 203 stanza.attr.to = jid; |
| 204 core_route_stanza(component, stanza); | 204 core_route_stanza(component, stanza); |
| 205 end | 205 end |
| 206 end | |
| 207 end | |
| 208 function broadcast_history(room, to) | |
| 209 local history = rooms_info:get(room, 'history'); -- send discussion history | |
| 210 if history then | |
| 211 for _, msg in ipairs(history) do | |
| 212 msg = st.deserialize(msg); | |
| 213 msg.attr.to=to; | |
| 214 core_route_stanza(component, msg); | |
| 215 end | |
| 216 end | |
| 217 if rooms_info:get(room, 'subject') then | |
| 218 core_route_stanza(component, st.message({type='groupchat', from=room, to=to}):tag("subject"):text(rooms_info:get(room, 'subject'))); | |
| 206 end | 219 end |
| 207 end | 220 end |
| 208 | 221 |
| 209 function handle_to_occupant(origin, stanza) -- PM, vCards, etc | 222 function handle_to_occupant(origin, stanza) -- PM, vCards, etc |
| 210 local from, to = stanza.attr.from, stanza.attr.to; | 223 local from, to = stanza.attr.from, stanza.attr.to; |
| 296 end | 309 end |
| 297 end | 310 end |
| 298 end | 311 end |
| 299 pr.attr.from = to; | 312 pr.attr.from = to; |
| 300 broadcast_presence_stanza(room, pr); | 313 broadcast_presence_stanza(room, pr); |
| 301 local history = rooms_info:get(room, 'history'); -- send discussion history | 314 broadcast_history(room, from); |
| 302 if history then | |
| 303 for _, msg in ipairs(history) do | |
| 304 msg = st.deserialize(msg); | |
| 305 msg.attr.to=from; | |
| 306 core_route_stanza(component, msg); | |
| 307 end | |
| 308 end | |
| 309 if rooms_info:get(room, 'subject') then | |
| 310 core_route_stanza(component, st.message({type='groupchat', from=room, to=from}):tag("subject"):text(rooms_info:get(room, 'subject'))); | |
| 311 end | |
| 312 end | 315 end |
| 313 end | 316 end |
| 314 elseif type ~= 'result' then -- bad type | 317 elseif type ~= 'result' then -- bad type |
| 315 origin.send(st.error_reply(stanza, "modify", "bad-request")); -- FIXME correct error? | 318 origin.send(st.error_reply(stanza, "modify", "bad-request")); -- FIXME correct error? |
| 316 end | 319 end |
