278 end, 1); |
278 end, 1); |
279 |
279 |
280 -- publish on unacked smacks message |
280 -- publish on unacked smacks message |
281 local function process_smacks_stanza(stanza, session) |
281 local function process_smacks_stanza(stanza, session) |
282 if session.push_identifier then |
282 if session.push_identifier then |
283 session.log("debug", "Invoking cloud handle_notify_request for smacks queued stanza"); |
283 session.log("debug", "Invoking cloud handle_notify_request() for smacks queued stanza"); |
284 local user_push_services = {[session.push_identifier] = session.push_settings}; |
284 local user_push_services = {[session.push_identifier] = session.push_settings}; |
285 local node = get_push_settings(stanza, session); |
285 local node = get_push_settings(stanza, session); |
286 handle_notify_request(stanza, node, user_push_services); |
286 handle_notify_request(stanza, node, user_push_services); |
287 end |
287 end |
288 return stanza; |
288 return stanza; |
|
289 end |
|
290 |
|
291 local function process_smacks_queue(queue, session) |
|
292 if not session.push_identifier then return; end |
|
293 local user_push_services = {[session.push_identifier] = session.push_settings}; |
|
294 for i=1, #queue do |
|
295 local stanza = queue[i]; |
|
296 local node = get_push_settings(stanza, session); |
|
297 session.log("debug", "Invoking cloud handle_notify_request() for smacks queued stanza: %d", i); |
|
298 if handle_notify_request(stanza, node, user_push_services) ~= 0 then |
|
299 session.log("debug", "Cloud handle_notify_request() > 0, not notifying for other queued stanzas"); |
|
300 return; -- only notify for one stanza in the queue, not for all in a row |
|
301 end |
|
302 end |
289 end |
303 end |
290 |
304 |
291 -- smacks hibernation is started |
305 -- smacks hibernation is started |
292 local function hibernate_session(event) |
306 local function hibernate_session(event) |
293 local session = event.origin; |
307 local session = event.origin; |
294 local queue = event.queue; |
308 local queue = event.queue; |
295 -- process unacked stanzas |
309 -- process unacked stanzas |
296 for i=1,#queue do |
310 process_smacks_queue(queue, session); |
297 process_smacks_stanza(queue[i], session); |
|
298 end |
|
299 -- process future unacked (hibernated) stanzas |
311 -- process future unacked (hibernated) stanzas |
300 filters.add_filter(session, "stanzas/out", process_smacks_stanza); |
312 filters.add_filter(session, "stanzas/out", process_smacks_stanza); |
301 end |
313 end |
302 |
314 |
303 -- smacks hibernation is ended |
315 -- smacks hibernation is ended |
316 -- smacks ack is delayed |
328 -- smacks ack is delayed |
317 local function ack_delayed(event) |
329 local function ack_delayed(event) |
318 local session = event.origin; |
330 local session = event.origin; |
319 local queue = event.queue; |
331 local queue = event.queue; |
320 -- process unacked stanzas (handle_notify_request() will only send push requests for new stanzas) |
332 -- process unacked stanzas (handle_notify_request() will only send push requests for new stanzas) |
321 for i=1,#queue do |
333 process_smacks_queue(queue, session); |
322 process_smacks_stanza(queue[i], session); |
|
323 end |
|
324 end |
334 end |
325 |
335 |
326 -- archive message added |
336 -- archive message added |
327 local function archive_message_added(event) |
337 local function archive_message_added(event) |
328 -- event is: { origin = origin, stanza = stanza, for_user = store_user, id = id } |
338 -- event is: { origin = origin, stanza = stanza, for_user = store_user, id = id } |