plugins/mod_privacy.lua

changeset 2590
2d7e2a28d1d5
parent 2589
39f5a068dc41
child 2614
7a589e9e2372
--- a/plugins/mod_privacy.lua	Thu Feb 11 18:44:42 2010 +0000
+++ b/plugins/mod_privacy.lua	Thu Feb 11 18:49:17 2010 +0000
@@ -118,13 +118,6 @@
 function activateList(privacy_lists, origin, stanza, which, name)
 	local list = privacy_lists.lists[name];
 
-	if privacy_lists.default == nil then
-		privacy_lists.default = "";
-	end
-	if origin.activePrivacyList == nil then
-		origin.activePrivacyList = "";
-	end
-	
 	if which == "default" and list then
 		if isAnotherSessionUsingDefaultList(origin) then
 			return {"cancel", "conflict", "Another session is online and using the default list."};
@@ -154,10 +147,10 @@
 			return {"cancel", "conflict", "Another session is online and using the list which should be deleted."};
 		end
 		if privacy_lists.default == name then
-			privacy_lists.default = "";
+			privacy_lists.default = nil;
 		end
 		if origin.activePrivacyList == name then
-			origin.activePrivacyList = "";
+			origin.activePrivacyList = nil;
 		end
 		privacy_lists.lists[name] = nil;
 		origin.send(st.reply(stanza));
@@ -272,9 +265,13 @@
 	reply:tag("query", {xmlns="jabber:iq:privacy"});
 
 	if name == nil then
-		reply:tag("active", {name=origin.activePrivacyList or ""}):up();
-		reply:tag("default", {name=privacy_lists.default or ""}):up();
 		if privacy_lists.lists then
+			if origin.ActivePrivacyList then
+				reply:tag("active", {name=origin.activePrivacyList}):up();
+			end
+			if privacy_lists.default then
+				reply:tag("default", {name=privacy_lists.default}):up();
+			end
 			for _,list in ipairs(privacy_lists.lists) do
 				reply:tag("list", {name=list.name}):up();
 			end
@@ -371,8 +368,7 @@
 	module:log("debug", "stanza: %s, to: %s, from: %s", tostring(stanza.name), tostring(to), tostring(from));
 	
 	if privacy_lists.lists == nil or
-		(session.activePrivacyList == nil or session.activePrivacyList == "") and
-		(privacy_lists.default == nil     or privacy_lists.default == "")
+		not (session.activePrivacyList or privacy_lists.default)
 	then
 		return; -- Nothing to block, default is Allow all
 	end
@@ -383,7 +379,7 @@
 	
 	local item;
 	local listname = session.activePrivacyList;
-	if listname == nil or listname == "" then
+	if listname == nil then
 		listname = privacy_lists.default; -- no active list selected, use default list
 	end
 	local list = privacy_lists.lists[listname];

mercurial