Diff

mod_carbons/mod_carbons.lua @ 585:ce2798a1bc56

mod_carbons: Don't try to send carbons for entirely offline users.
author Kim Alvefur <zash@zash.se>
date Sat, 28 Jan 2012 15:10:04 +0100
parent 545:77f350635f4f
child 605:5175f6d33470
line wrap: on
line diff
--- 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