Software /
code /
prosody
Comparison
core/stanza_router.lua @ 249:1fc47cf5d144
Added basic offline message support
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Thu, 13 Nov 2008 12:13:13 +0500 |
parent | 237:c1e9b3f3f3a7 |
child | 250:9f66ede8deeb |
comparison
equal
deleted
inserted
replaced
248:8ce9559d501a | 249:1fc47cf5d144 |
---|---|
11 local send_s2s = require "core.s2smanager".send_to_host; | 11 local send_s2s = require "core.s2smanager".send_to_host; |
12 local user_exists = require "core.usermanager".user_exists; | 12 local user_exists = require "core.usermanager".user_exists; |
13 | 13 |
14 local rostermanager = require "core.rostermanager"; | 14 local rostermanager = require "core.rostermanager"; |
15 local sessionmanager = require "core.sessionmanager"; | 15 local sessionmanager = require "core.sessionmanager"; |
16 local offlinemanager = require "core.offlinemanager"; | |
16 | 17 |
17 local s2s_verify_dialback = require "core.s2smanager".verify_dialback; | 18 local s2s_verify_dialback = require "core.s2smanager".verify_dialback; |
18 local s2s_make_authenticated = require "core.s2smanager".make_authenticated; | 19 local s2s_make_authenticated = require "core.s2smanager".make_authenticated; |
19 | 20 |
20 local modules_handle_stanza = require "core.modulemanager".handle_stanza; | 21 local modules_handle_stanza = require "core.modulemanager".handle_stanza; |
147 if item.ask then | 148 if item.ask then |
148 request.attr.to = jid; | 149 request.attr.to = jid; |
149 core_route_stanza(origin, request); | 150 core_route_stanza(origin, request); |
150 end | 151 end |
151 end | 152 end |
153 for _, msg in ipairs(offlinemanager.load(node, host) or {}) do | |
154 origin.send(msg); -- FIXME do we need to modify to/from in any way? | |
155 end | |
156 offlinemanager.deleteAll(node, host); | |
152 end | 157 end |
153 origin.priority = 0; | 158 origin.priority = 0; |
154 if stanza.attr.type == "unavailable" then | 159 if stanza.attr.type == "unavailable" then |
155 origin.presence = nil; | 160 origin.presence = nil; |
156 else | 161 else |
326 recipients = {session}; | 331 recipients = {session}; |
327 elseif p == priority then | 332 elseif p == priority then |
328 t_insert(recipients, session); | 333 t_insert(recipients, session); |
329 end | 334 end |
330 end | 335 end |
336 local count = 0; | |
331 for _, session in pairs(recipients) do | 337 for _, session in pairs(recipients) do |
332 session.send(stanza); | 338 session.send(stanza); |
339 count = count + 1; | |
340 end | |
341 if count == 0 then | |
342 offlinemanager.store(node, host, stanza); | |
343 -- TODO deal with storage errors | |
333 end | 344 end |
334 else | 345 else |
335 -- TODO send IQ error | 346 -- TODO send IQ error |
336 end | 347 end |
337 else | 348 else |
347 handle_inbound_presence_subscriptions_and_probes(origin, stanza, from_bare, to_bare); | 358 handle_inbound_presence_subscriptions_and_probes(origin, stanza, from_bare, to_bare); |
348 else | 359 else |
349 -- TODO send unavailable presence or unsubscribed | 360 -- TODO send unavailable presence or unsubscribed |
350 end | 361 end |
351 elseif stanza.name == "message" then | 362 elseif stanza.name == "message" then |
352 -- TODO send message error, or store offline messages | 363 if stanza.attr.type == "chat" or stanza.attr.type == "normal" or not stanza.attr.type then |
364 offlinemanager.store(node, host, stanza); | |
365 -- FIXME don't store messages with only chat state notifications | |
366 end | |
367 -- TODO allow configuration of offline storage | |
368 -- TODO send error if not storing offline | |
353 elseif stanza.name == "iq" then | 369 elseif stanza.name == "iq" then |
354 -- TODO send IQ error | 370 -- TODO send IQ error |
355 end | 371 end |
356 else -- user does not exist | 372 else -- user does not exist |
357 -- TODO we would get here for nodeless JIDs too. Do something fun maybe? Echo service? Let plugins use xmpp:server/resource addresses? | 373 -- TODO we would get here for nodeless JIDs too. Do something fun maybe? Echo service? Let plugins use xmpp:server/resource addresses? |