rostermanager: do not save rosters for unexistant users.
authorMarco Cirillo <maranda@lightwitch.org>
Fri, 5 Apr 2013 04:52:11 +0000 (04:52 +0000)
committerMarco Cirillo <maranda@lightwitch.org>
Fri, 5 Apr 2013 04:52:11 +0000 (04:52 +0000)
core/rostermanager.lua

index f14bb435950788dbba2b3114a91209164298a9e6..5e06e3f7a4203ec5c82971f638f4b81322c9e74a 100644 (file)
@@ -18,6 +18,7 @@ local hosts = hosts;
 local bare_sessions = bare_sessions;
 
 local datamanager = require "util.datamanager"
+local um_user_exists = require "core.usermanager".user_exists;
 local st = require "util.stanza";
 
 module "rostermanager"
@@ -105,6 +106,11 @@ function load_roster(username, host)
 end
 
 function save_roster(username, host, roster)
+       if not um_user_exists(username, host) then
+               log("debug", "not saving roster for %s@%s: the user doesn't exist", username, host);
+               return nil;
+       end
+
        log("debug", "save_roster: saving roster for %s@%s", username, host);
        if not roster then
                roster = hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster;