mod_carbons: Don't try to send carbons for entirely offline users.
authorKim Alvefur <zash@zash.se>
Sat, 28 Jan 2012 15:10:04 +0100
changeset 585 ce2798a1bc56
parent 584 1c2fc3b845f2
child 587 f733e7599ed6
mod_carbons: Don't try to send carbons for entirely offline users.
mod_carbons/mod_carbons.lua
--- a/mod_carbons/mod_carbons.lua	Thu Jan 26 19:38:03 2012 +0100
+++ b/mod_carbons/mod_carbons.lua	Sat Jan 28 15:10:04 2012 +0100
@@ -54,14 +54,20 @@
 		user_sessions = host_sessions[username];
 		if resource then
 			no_carbon_to[resource] = true;
-		else
+		elseif user_sessions then
 			local top_resources = user_sessions.top_resources;
-			for _, session in ipairs(top_resources) do
-				no_carbon_to[session.resource] = true;
+			if top_resources then
+				for _, session in ipairs(top_resources) do
+					no_carbon_to[session.resource] = true;
+				end
 			end
 		end
 	end
 
+	if not user_sessions then
+		return -- No use in sending carbons to an offline user
+	end
+
 	if not c2s and stanza:get_child("private", xmlns_carbons) then
 		stanza:maptags(function(tag)
 			return tag.attr.xmlns == xmlns_carbons