# HG changeset patch # User Thilo Cestonaro # Date 1254170161 -7200 # Node ID 2df11ec081fe4b07321550a49bee1d90f8de9caa # Parent ccb07c0efc7e44a5ae653984c9db71979f78c580 mod_privacy: make finding the right session working diff -r ccb07c0efc7e -r 2df11ec081fe mod_privacy/mod_privacy.lua --- a/mod_privacy/mod_privacy.lua Mon Sep 28 22:22:22 2009 +0200 +++ b/mod_privacy/mod_privacy.lua Mon Sep 28 22:36:01 2009 +0200 @@ -389,16 +389,22 @@ if resource == nil then local prio = 0; local session_; - for _,session_ in ipairs(bare_sessions[node.."@"..host].sessions) do - if session_.priority > prio then - session = session_; - prio = session_.priority; + if bare_sessions[node.."@"..host] ~= nil then + for resource, session_ in pairs(bare_sessions[node.."@"..host].sessions) do + if session_.priority > prio then + session = session_; + prio = session_.priority; + end end end else session = full_sessions[node.."@"..host.."/"..resource]; end - return checkIfNeedToBeBlocked(e, session); + if session ~= nil then + return checkIfNeedToBeBlocked(e, session); + else + module:log("debug", "preCheckIncoming: Couldn't get session for jid: %s@%s/%s", node or "nil", host or "nil", resource or "nil") + end end return; end @@ -413,16 +419,22 @@ if resource == nil then local prio = 0; local session_; - for _,session_ in ipairs(bare_sessions[node.."@"..host].sessions) do - if session_.priority > prio then - session = session_; - prio = session_.priority; + if bare_sessions[node.."@"..host] ~= nil then + for resource, session_ in pairs(bare_sessions[node.."@"..host].sessions) do + if session_.priority > prio then + session = session_; + prio = session_.priority; + end end end else session = full_sessions[node.."@"..host.."/"..resource]; end - return checkIfNeedToBeBlocked(e, session); + if session ~= nil then + return checkIfNeedToBeBlocked(e, session); + else + module:log("debug", "preCheckOutgoing: Couldn't get session for jid: %s@%s/%s", node or "nil", host or "nil", resource or "nil") + end end return; end