Diff

core/rostermanager.lua @ 5429:25333de6e7c7

rostermanager: do not save rosters for unexistant users.
author Marco Cirillo <maranda@lightwitch.org>
date Fri, 05 Apr 2013 04:52:11 +0000
parent 5348:ca0d820e9318
child 5747:23076ee191d3
child 7777:65836cf2d057
line wrap: on
line diff
--- a/core/rostermanager.lua	Fri Apr 05 04:49:32 2013 +0000
+++ b/core/rostermanager.lua	Fri Apr 05 04:52:11 2013 +0000
@@ -18,6 +18,7 @@
 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 @@
 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;