diff options
author | Robert Hoelz <rob@hoelz.ro> | 2010-10-15 00:53:05 -0500 |
---|---|---|
committer | Robert Hoelz <rob@hoelz.ro> | 2010-10-15 00:53:05 -0500 |
commit | c74e3999fb155de1015568aa9b79477f25d94e7d (patch) | |
tree | 1b9b999edc335b1adbd0e6224d35ce013eac6ab0 /plugins/mod_presence.lua | |
parent | 26cf54ee8be9c24baf35bd9a50c9b1b77c0849f0 (diff) | |
download | prosody-c74e3999fb155de1015568aa9b79477f25d94e7d.tar.gz prosody-c74e3999fb155de1015568aa9b79477f25d94e7d.zip |
Don't send offline messages to resource with negative priorities
Diffstat (limited to 'plugins/mod_presence.lua')
-rw-r--r-- | plugins/mod_presence.lua | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua index 8e6ef85a..ab2cac38 100644 --- a/plugins/mod_presence.lua +++ b/plugins/mod_presence.lua @@ -59,6 +59,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 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 @@ function handle_normal_presence(origin, stanza) 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 @@ function handle_normal_presence(origin, stanza) 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); |