Diff

plugins/mod_blocklist.lua @ 6502:8fed6ea12098

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Sun, 26 Oct 2014 20:58:02 +0100
parent 6495:44df423f8290
child 6531:18f4973849b1
line wrap: on
line diff
--- a/plugins/mod_blocklist.lua	Wed Oct 22 16:00:40 2014 -0400
+++ b/plugins/mod_blocklist.lua	Sun Oct 26 20:58:02 2014 +0100
@@ -43,7 +43,6 @@
 -- Migrates from the old mod_privacy storage
 local function migrate_privacy_list(username)
 	local migrated_data = { [false] = "not empty" };
-	module:log("info", "Migrating blocklist from mod_privacy storage for user '%s'", username);
 	local legacy_data = module:open_store("privacy"):get(username);
 	if legacy_data and legacy_data.lists and legacy_data.default then
 		legacy_data = legacy_data.lists[legacy_data.default];
@@ -52,6 +51,7 @@
 		return migrated_data;
 	end
 	if legacy_data then
+		module:log("info", "Migrating blocklist from mod_privacy storage for user '%s'", username);
 		local item, jid;
 		for i = 1, #legacy_data do
 			item = legacy_data[i];
@@ -149,7 +149,9 @@
 		for jid, in_roster in pairs(new) do
 			if not blocklist[jid] and in_roster and sessions[username] then
 				for _, session in pairs(sessions[username].sessions) do
-					module:send(st.presence({ type = "unavailable", to = jid, from = session.full_jid }));
+					if session.presence then
+						module:send(st.presence({ type = "unavailable", to = jid, from = session.full_jid }));
+					end
 				end
 			end
 		end