# HG changeset patch # User Matthew Wild <mwild1@gmail.com> # Date 1287158837 -3600 # Node ID 489b683988fe9b3d05cb4db78dcbebb5b65655cd # Parent 530f7de1d265bd3d4d7b62223454c508511f9d56# Parent d3399d1b484ae900fa9824584e11a4acb292b7a6 Merge hoelzro->trunk diff -r 530f7de1d265 -r 489b683988fe plugins/mod_presence.lua --- a/plugins/mod_presence.lua Tue Oct 12 23:42:28 2010 +0200 +++ b/plugins/mod_presence.lua Fri Oct 15 17:07:17 2010 +0100 @@ -59,6 +59,15 @@ 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 if full_sessions[origin.full_jid] then -- if user is still connected origin.send(stanza); -- reflect their presence back to them end @@ -105,13 +114,16 @@ core_post_stanza(origin, request, true); end end - 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 + + 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 end if stanza.attr.type == "unavailable" then origin.presence = nil; @@ -128,15 +140,6 @@ end else origin.presence = stanza; - 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 origin.priority ~= priority then origin.priority = priority; recalc_resource_map(user);