Diff

mod_roster_command/mod_roster_command.lua @ 1509:01e37ce7532e

mod_roster_command: Make sure hosts are only initialized once
author Kim Alvefur <zash@zash.se>
date Sat, 20 Sep 2014 11:33:49 +0200
parent 1508:f7cb287dd3c7
child 1565:f9cb09d451c7
line wrap: on
line diff
--- a/mod_roster_command/mod_roster_command.lua	Sat Sep 20 11:31:41 2014 +0200
+++ b/mod_roster_command/mod_roster_command.lua	Sat Sep 20 11:33:49 2014 +0200
@@ -33,12 +33,14 @@
 		warn("The host '%s' is not configured for this server.", user_host);
 		return;
 	end
-	storagemanager.initialize_host(user_host);
-	usermanager.initialize_host(user_host);
+	if hosts[user_host].users.name == "null" then
+		storagemanager.initialize_host(user_host);
+		usermanager.initialize_host(user_host);
+	end
 	-- Update user's roster to say subscription request is pending...
 	rostermanager.set_contact_pending_out(user_username, user_host, contact_jid);
 	if hosts[contact_host] then
-		if contact_host ~= user_host then
+		if contact_host ~= user_host and hosts[contact_host].users.name == "null" then
 			storagemanager.initialize_host(contact_host);
 			usermanager.initialize_host(contact_host);
 		end
@@ -66,12 +68,14 @@
 		warn("The host '%s' is not configured for this server.", user_host);
 		return;
 	end
-	storagemanager.initialize_host(user_host);
-	usermanager.initialize_host(user_host);
+	if hosts[user_host].users.name == "null" then
+		storagemanager.initialize_host(user_host);
+		usermanager.initialize_host(user_host);
+	end
 	-- Update user's roster to say subscription is cancelled...
 	rostermanager.unsubscribe(user_username, user_host, contact_jid);
 	if hosts[contact_host] then
-		if contact_host ~= user_host then
+		if contact_host ~= user_host and hosts[contact_host].users.name == "null" then
 			storagemanager.initialize_host(contact_host);
 			usermanager.initialize_host(contact_host);
 		end
@@ -93,8 +97,10 @@
 		warn("The host '%s' is not configured for this server.", user_host);
 		return;
 	end
-	storagemanager.initialize_host(user_host);
-	usermanager.initialize_host(user_host);
+	if hosts[user_host].users.name == "null" then
+		storagemanager.initialize_host(user_host);
+		usermanager.initialize_host(user_host);
+	end
 
 	-- Load user's roster and find the contact
 	local roster = rostermanager.load_roster(user_username, user_host);