Diff

core/rostermanager.lua @ 1897:6d81e74310a7

rostermanager: Added support for saving rosters of offline users to the save_roster function.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 04 Oct 2009 21:25:59 +0500
parent 1523:841d61be198f
child 1898:1ce02e2f5a3f
line wrap: on
line diff
--- a/core/rostermanager.lua	Fri Oct 02 22:37:03 2009 +0100
+++ b/core/rostermanager.lua	Sun Oct 04 21:25:59 2009 +0500
@@ -102,9 +102,16 @@
 	return roster;
 end
 
-function save_roster(username, host)
+function save_roster(username, host, roster)
 	log("debug", "save_roster: saving roster for "..username.."@"..host);
-	if hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster then
+	if not roster then
+		roster = hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster;
+		--if not roster then
+		--	--roster = load_roster(username, host);
+		--	return true; -- roster unchanged, no reason to save
+		--end
+	end
+	if roster then
 		local roster = hosts[host].sessions[username].roster;
 		roster[false].version = (roster[false].version or 1) + 1;
 		return datamanager.store(username, host, "roster", hosts[host].sessions[username].roster);