Comparison

core/rostermanager.lua @ 2048:d420722519e1

rostermanager: Log a warning when a self-contact is detected.
author Waqas Hussain <waqas20@gmail.com>
date Thu, 22 Oct 2009 03:38:00 +0500
parent 2047:fb236904c959
child 2049:227f3fd2caaf
comparison
equal deleted inserted replaced
2047:fb236904c959 2048:d420722519e1
79 end 79 end
80 end 80 end
81 end 81 end
82 82
83 function load_roster(username, host) 83 function load_roster(username, host)
84 log("debug", "load_roster: asked for: "..username.."@"..host); 84 local jid = username.."@"..host;
85 log("debug", "load_roster: asked for: "..jid);
85 local roster; 86 local roster;
86 if hosts[host] and hosts[host].sessions[username] then 87 if hosts[host] and hosts[host].sessions[username] then
87 roster = hosts[host].sessions[username].roster; 88 roster = hosts[host].sessions[username].roster;
88 if not roster then 89 if not roster then
89 log("debug", "load_roster: loading for new user: "..username.."@"..host); 90 log("debug", "load_roster: loading for new user: "..username.."@"..host);
90 roster = datamanager.load(username, host, "roster") or {}; 91 roster = datamanager.load(username, host, "roster") or {};
91 if not roster[false] then roster[false] = { }; end 92 if not roster[false] then roster[false] = { }; end
92 roster[username.."@"..host] = nil; 93 if roster[jid] then
94 roster[jid] = nil;
95 log("warn", "roster for "..jid.." has a self-contact");
96 end
93 hosts[host].sessions[username].roster = roster; 97 hosts[host].sessions[username].roster = roster;
94 hosts[host].events.fire_event("roster-load", username, host, roster); 98 hosts[host].events.fire_event("roster-load", username, host, roster);
95 end 99 end
96 return roster; 100 return roster;
97 end 101 end
98 102
99 -- Attempt to load roster for non-loaded user 103 -- Attempt to load roster for non-loaded user
100 log("debug", "load_roster: loading for offline user: "..username.."@"..host); 104 log("debug", "load_roster: loading for offline user: "..username.."@"..host);
101 roster = datamanager.load(username, host, "roster") or {}; 105 roster = datamanager.load(username, host, "roster") or {};
102 if not roster[false] then roster[false] = { }; end 106 if not roster[false] then roster[false] = { }; end
103 roster[username.."@"..host] = nil; 107 if roster[jid] then
108 roster[jid] = nil;
109 log("warn", "roster for "..jid.." has a self-contact");
110 end
104 hosts[host].events.fire_event("roster-load", username, host, roster); 111 hosts[host].events.fire_event("roster-load", username, host, roster);
105 return roster; 112 return roster;
106 end 113 end
107 114
108 function save_roster(username, host, roster) 115 function save_roster(username, host, roster)