Changeset

5918:423163b65bb1

mod_csi_battery_saver: Some more improvements (handling of errors, muc invites, special data)
author tmolitor <thilo@eightysoft.de>
date Mon, 29 Apr 2024 02:00:34 +0200
parents 5917:5db53d619e66
children 5919:095030677ae6
files mod_csi_battery_saver/mod_csi_battery_saver.lua
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_csi_battery_saver/mod_csi_battery_saver.lua	Mon Apr 29 01:31:40 2024 +0200
+++ b/mod_csi_battery_saver/mod_csi_battery_saver.lua	Mon Apr 29 02:00:34 2024 +0200
@@ -85,6 +85,17 @@
 end
 
 local function is_important(stanza, session)
+	-- some special handlings
+	if stanza == " " then						-- whitespace keepalive
+		return true;
+	elseif type(stanza) == "string" then		-- raw data
+		return true;
+	elseif not st.is_stanza(stanza) then		-- this should probably never happen
+		return true;
+	end
+	if stanza.attr.xmlns ~= nil then			-- nonzas (stream errors, stream management etc.)
+		return true;
+	end
 	local st_name = stanza and stanza.name or nil;
 	if not st_name then return true; end	-- nonzas are always important
 	if st_name == "presence" then
@@ -104,6 +115,9 @@
 
 		local st_type = stanza.attr.type;
 
+		-- errors are always important
+		if st_type == "error" then return true; end;
+
 		-- headline message are always not important, with some exceptions
 		if st_type == "headline" then
 			-- allow headline pushes of mds updates (XEP-0490)
@@ -111,6 +125,10 @@
 			return false
 		end
 
+		-- mediated muc invites
+		if stanza:find("{http://jabber.org/protocol/muc#user}x/invite") then return true; end;
+		if stanza:get_child("x", "jabber:x:conference") then return true; end;
+
 		-- chat markers (XEP-0333) are important, too, because some clients use them to update their notifications
 		if stanza:child_with_ns("urn:xmpp:chat-markers:0") then return true; end;