configmanager: Added rawget().
[prosody.git] / plugins / mod_presence.lua
index ab2cac38a9ce379410b08acffc96a0e981db6d2c..61239c9ac5b48bc7db84f598acf99c52ac7b9db0 100644 (file)
@@ -22,7 +22,6 @@ local NULL = {};
 
 local rostermanager = require "core.rostermanager";
 local sessionmanager = require "core.sessionmanager";
-local offlinemanager = require "core.offlinemanager";
 
 local function select_top_resources(user)
        local priority = 0;
@@ -59,15 +58,15 @@ function handle_normal_presence(origin, stanza)
                        priority[1] = "0";
                end
        end
-        local priority = stanza:child_with_name("priority");
-        if priority and #priority > 0 then
-                priority = t_concat(priority);
-                if s_find(priority, "^[+-]?[0-9]+$") then
-                        priority = tonumber(priority);
-                        if priority < -128 then priority = -128 end
-                        if priority > 127 then priority = 127 end
-                else priority = 0; end
-        else priority = 0; end
+       local priority = stanza:child_with_name("priority");
+       if priority and #priority > 0 then
+               priority = t_concat(priority);
+               if s_find(priority, "^[+-]?[0-9]+$") then
+                       priority = tonumber(priority);
+                       if priority < -128 then priority = -128 end
+                       if priority > 127 then priority = 127 end
+               else priority = 0; end
+       else priority = 0; end
        if full_sessions[origin.full_jid] then -- if user is still connected
                origin.send(stanza); -- reflect their presence back to them
        end
@@ -115,15 +114,10 @@ function handle_normal_presence(origin, stanza)
                        end
                end
 
-                if priority >= 0 then
-                        local offline = offlinemanager.load(node, host);
-                        if offline then
-                                for _, msg in ipairs(offline) do
-                                        origin.send(msg); -- FIXME do we need to modify to/from in any way?
-                                end
-                                offlinemanager.deleteAll(node, host);
-                        end
-                end
+               if priority >= 0 then
+                        local event = { origin = origin }
+                        module:fire_event('message/offline/broadcast', event);
+               end
        end
        if stanza.attr.type == "unavailable" then
                origin.presence = nil;