diff options
author | Waqas Hussain <waqas20@gmail.com> | 2009-10-22 03:46:54 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2009-10-22 03:46:54 +0500 |
commit | c3555f641ab84d2e22df2688b9cf03d26f1a7da9 (patch) | |
tree | 5f2dbe9cab1eccfd36e0285f9d1eeab1ca46572a /core | |
parent | eab91c4f75ae83515b2c576d540fbd3c84cb0943 (diff) | |
download | prosody-c3555f641ab84d2e22df2688b9cf03d26f1a7da9.tar.gz prosody-c3555f641ab84d2e22df2688b9cf03d26f1a7da9.zip |
rostermanager: Refactored roster loading to remove duplicate code.
Diffstat (limited to 'core')
-rw-r--r-- | core/rostermanager.lua | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/core/rostermanager.lua b/core/rostermanager.lua index a3aaf6f1..fe104f14 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -83,26 +83,17 @@ end function load_roster(username, host) local jid = username.."@"..host; log("debug", "load_roster: asked for: "..jid); + local user = bare_sessions[jid]; local roster; - if hosts[host] and hosts[host].sessions[username] then - roster = hosts[host].sessions[username].roster; - if not roster then - 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 - 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 - return roster; + if user then + roster = user.roster; + if roster then return roster; end + log("debug", "load_roster: loading for new user: "..username.."@"..host); + else -- Attempt to load roster for non-loaded user + log("debug", "load_roster: loading for offline user: "..username.."@"..host); end - - -- Attempt to load roster for non-loaded user - log("debug", "load_roster: loading for offline user: "..username.."@"..host); roster = datamanager.load(username, host, "roster") or {}; + if user then user.roster = roster; end if not roster[false] then roster[false] = { }; end if roster[jid] then roster[jid] = nil; |