Comparison

mod_privacy/mod_privacy.lua @ 18:2df11ec081fe

mod_privacy: make finding the right session working
author Thilo Cestonaro <thilo@cestona.ro>
date Mon, 28 Sep 2009 22:36:01 +0200
parent 17:ccb07c0efc7e
child 19:e400ee8471b0
comparison
equal deleted inserted replaced
17:ccb07c0efc7e 18:2df11ec081fe
387 return; 387 return;
388 end 388 end
389 if resource == nil then 389 if resource == nil then
390 local prio = 0; 390 local prio = 0;
391 local session_; 391 local session_;
392 for _,session_ in ipairs(bare_sessions[node.."@"..host].sessions) do 392 if bare_sessions[node.."@"..host] ~= nil then
393 if session_.priority > prio then 393 for resource, session_ in pairs(bare_sessions[node.."@"..host].sessions) do
394 session = session_; 394 if session_.priority > prio then
395 prio = session_.priority; 395 session = session_;
396 prio = session_.priority;
397 end
396 end 398 end
397 end 399 end
398 else 400 else
399 session = full_sessions[node.."@"..host.."/"..resource]; 401 session = full_sessions[node.."@"..host.."/"..resource];
400 end 402 end
401 return checkIfNeedToBeBlocked(e, session); 403 if session ~= nil then
404 return checkIfNeedToBeBlocked(e, session);
405 else
406 module:log("debug", "preCheckIncoming: Couldn't get session for jid: %s@%s/%s", node or "nil", host or "nil", resource or "nil")
407 end
402 end 408 end
403 return; 409 return;
404 end 410 end
405 411
406 function preCheckOutgoing(e) 412 function preCheckOutgoing(e)
411 return; 417 return;
412 end 418 end
413 if resource == nil then 419 if resource == nil then
414 local prio = 0; 420 local prio = 0;
415 local session_; 421 local session_;
416 for _,session_ in ipairs(bare_sessions[node.."@"..host].sessions) do 422 if bare_sessions[node.."@"..host] ~= nil then
417 if session_.priority > prio then 423 for resource, session_ in pairs(bare_sessions[node.."@"..host].sessions) do
418 session = session_; 424 if session_.priority > prio then
419 prio = session_.priority; 425 session = session_;
426 prio = session_.priority;
427 end
420 end 428 end
421 end 429 end
422 else 430 else
423 session = full_sessions[node.."@"..host.."/"..resource]; 431 session = full_sessions[node.."@"..host.."/"..resource];
424 end 432 end
425 return checkIfNeedToBeBlocked(e, session); 433 if session ~= nil then
434 return checkIfNeedToBeBlocked(e, session);
435 else
436 module:log("debug", "preCheckOutgoing: Couldn't get session for jid: %s@%s/%s", node or "nil", host or "nil", resource or "nil")
437 end
426 end 438 end
427 return; 439 return;
428 end 440 end
429 441
430 442