plugins/mod_presence.lua

changeset 3968
048af3ee5899
parent 3540
bc139431830b
child 3969
32d4a73901e2
equal deleted inserted replaced
3967:1a9bcbaeb55a 3968:048af3ee5899
20 local hosts = hosts; 20 local hosts = hosts;
21 local NULL = {}; 21 local NULL = {};
22 22
23 local rostermanager = require "core.rostermanager"; 23 local rostermanager = require "core.rostermanager";
24 local sessionmanager = require "core.sessionmanager"; 24 local sessionmanager = require "core.sessionmanager";
25 local offlinemanager = require "core.offlinemanager";
26 25
27 local function select_top_resources(user) 26 local function select_top_resources(user)
28 local priority = 0; 27 local priority = 0;
29 local recipients = {}; 28 local recipients = {};
30 for _, session in pairs(user.sessions) do -- find resource with greatest priority 29 for _, session in pairs(user.sessions) do -- find resource with greatest priority
114 core_post_stanza(origin, request, true); 113 core_post_stanza(origin, request, true);
115 end 114 end
116 end 115 end
117 116
118 if priority >= 0 then 117 if priority >= 0 then
119 local offline = offlinemanager.load(node, host); 118 local event = { origin = origin }
120 if offline then 119 module:fire_event('message/offline/broadcast', event);
121 for _, msg in ipairs(offline) do 120 module:fire_event('message/offline/delete', event);
122 origin.send(msg); -- FIXME do we need to modify to/from in any way?
123 end
124 offlinemanager.deleteAll(node, host);
125 end
126 end 121 end
127 end 122 end
128 if stanza.attr.type == "unavailable" then 123 if stanza.attr.type == "unavailable" then
129 origin.presence = nil; 124 origin.presence = nil;
130 if origin.priority then 125 if origin.priority then

mercurial