diff mod_manifesto/mod_manifesto.lua @ 1324:853a382c9bd6

mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
author Kim Alvefur <zash@zash.se>
date Fri, 28 Feb 2014 15:36:06 +0100
parents 9ddfff2acddc
children b21236b6b8d8
line wrap: on
line diff
--- a/mod_manifesto/mod_manifesto.lua	Wed Feb 26 13:08:47 2014 -0800
+++ b/mod_manifesto/mod_manifesto.lua	Fri Feb 28 15:36:06 2014 +0100
@@ -57,14 +57,18 @@
 
 module:hook("resource-bind", function (event)
 	local session = event.session;
+	module:log("debug", "mod_%s sees that %s logged in", module.name, session.username);
 
 	local now = time();
 	local last_notify = notified[session.username] or 0;
 	if last_notify > ( now - 86400 * 7 ) then
+		module:log("debug", "Already notified %s", session.username);
 		return
 	end
 
+	module:log("debug", "Waiting 15 seconds");
 	timer.add_task(15, function ()
+		module:log("debug", "15 seconds later... session.type is %q", session.type);
 		if session.type ~= "c2s" then return end -- user quit already
 		local bad_contacts, bad_hosts = {}, {};
 		for contact_jid, item in pairs(session.roster or {}) do
@@ -96,6 +100,7 @@
 				end
 			end
 		end
+		module:log("debug", "%s has %d bad contacts", session.username, #bad_contacts);
 		if #bad_contacts > 0 then
 			local vars = {
 				HOST = host;
@@ -103,6 +108,7 @@
 				SERVICES = "    "..table.concat(bad_hosts, "\n    ");
 				CONTACTVIA = contact_method, CONTACT = contact;
 			};
+			module:log("debug", "Sending notification to %s", session.username);
 			session.send(st.message({ type = "headline", from = host }):tag("body"):text(message:gsub("$(%w+)", vars)));
 			notified[session.username] = now;
 		end
@@ -159,7 +165,7 @@
 		config_set(host, "s2s_require_encryption", true);
 
 		for _, session in pairs(s2s_sessions) do
-			if not session.secure then
+			if session.type == "s2sin" or session.type == "s2sout" and not session.secure then
 				(session.close or s2s_destroy_session)(session);
 			end
 		end