From eab91c4f75ae83515b2c576d540fbd3c84cb0943 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Thu, 22 Oct 2009 03:38:00 +0500 Subject: rostermanager: Log a warning when a self-contact is detected. --- core/rostermanager.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core/rostermanager.lua b/core/rostermanager.lua index b415c21c..a3aaf6f1 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -81,7 +81,8 @@ function roster_push(username, host, jid) end function load_roster(username, host) - log("debug", "load_roster: asked for: "..username.."@"..host); + local jid = username.."@"..host; + log("debug", "load_roster: asked for: "..jid); local roster; if hosts[host] and hosts[host].sessions[username] then roster = hosts[host].sessions[username].roster; @@ -89,7 +90,10 @@ function load_roster(username, host) log("debug", "load_roster: loading for new user: "..username.."@"..host); roster = datamanager.load(username, host, "roster") or {}; if not roster[false] then roster[false] = { }; end - roster[username.."@"..host] = nil; + if roster[jid] then + roster[jid] = nil; + log("warn", "roster for "..jid.." has a self-contact"); + end hosts[host].sessions[username].roster = roster; hosts[host].events.fire_event("roster-load", username, host, roster); end @@ -100,7 +104,10 @@ function load_roster(username, host) log("debug", "load_roster: loading for offline user: "..username.."@"..host); roster = datamanager.load(username, host, "roster") or {}; if not roster[false] then roster[false] = { }; end - roster[username.."@"..host] = nil; + if roster[jid] then + roster[jid] = nil; + log("warn", "roster for "..jid.." has a self-contact"); + end hosts[host].events.fire_event("roster-load", username, host, roster); return roster; end -- cgit v1.2.3