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 |