mod_csi_battery_saver: Ignore CSI actions before resource bind
authortmolitor <thilo@eightysoft.de>
Mon, 22 Jun 2020 21:35:57 +0200
changeset 4052 64b7daa6c42c
parent 4051 36b6e3e3f9e2
child 4053 78f1de5301fc
mod_csi_battery_saver: Ignore CSI actions before resource bind
mod_csi_battery_saver/mod_csi_battery_saver.lua
--- a/mod_csi_battery_saver/mod_csi_battery_saver.lua	Thu Jun 18 15:24:34 2020 +0200
+++ b/mod_csi_battery_saver/mod_csi_battery_saver.lua	Mon Jun 22 21:35:57 2020 +0200
@@ -150,6 +150,10 @@
 
 module:hook("csi-client-inactive", function (event)
 	local session = event.origin;
+	if not session.resource then
+		session.log("warn", "Ignoring csi if no resource is bound!");
+		return;
+	end
 	if session.pump then
 		session.log("debug", "mod_csi_battery_saver(%s): Client is inactive, buffering unimportant outgoing stanzas", id);
 		session.pump:pause();
@@ -179,6 +183,10 @@
 
 module:hook("csi-client-active", function (event)
 	local session = event.origin;
+	if not session.resource then
+		session.log("warn", "Ignoring csi if no resource is bound!");
+		return;
+	end
 	if session.pump then
 		session.log("debug", "mod_csi_battery_saver(%s): Client is active, resuming direct delivery", id);
 		session.pump:resume();