changeset 2755:dbab58abd3e2

Merge with zash
author tmolitor <thilo@eightysoft.de>
date Sun, 27 Aug 2017 21:16:37 +0200
parents d1aa5fc005f7 (diff) 77adb2b5c847 (current diff)
children dbba101601b4
files
diffstat 2 files changed, 23 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/mod_csi_battery_saver/README.markdown	Sun Aug 27 21:11:26 2017 +0200
+++ b/mod_csi_battery_saver/README.markdown	Sun Aug 27 21:16:37 2017 +0200
@@ -17,12 +17,13 @@
 allowing for power usage savings by not requiring mobile clients to
 bring up their radio for unimportant stanzas.
 
-`IQ` stanzas, and `message` stanzas containing a body or being encypted
-and all nonzas are considered important.
+`IQ` stanzas, and `message` stanzas containing a body or being encrypted,
+chat markers (see [XEP-0333]) and all nonzas are considered important.
 If the config option `csi_battery_saver_filter_muc` is set to true,
 groupchat messages must set a subject or have the user's username or nickname
-in their messages to count as "important", if the config is false (default), all
-groupchat messages havin a body or being encrypted are considered "important".
+in their messages (or be encrypted) to count as "important", if this option
+is set to false (default), all groupchat messages having a body
+or being encrypted are considered "important".
 `Presence` stanzas are always considered not "important".
 
 All buffered stanzas that allow timestamping are properly stamped to
--- a/mod_csi_battery_saver/mod_csi_battery_saver.lua	Sun Aug 27 21:11:26 2017 +0200
+++ b/mod_csi_battery_saver/mod_csi_battery_saver.lua	Sun Aug 27 21:16:37 2017 +0200
@@ -107,32 +107,36 @@
 		-- unpack carbon copies
 		local stanza_direction = "in";
 		local carbon;
+		local st_type;
 		-- support carbon copied message stanzas having an arbitrary message-namespace or no message-namespace at all
 		if not carbon then carbon = find(stanza, "{urn:xmpp:carbons:2}/forwarded/message"); end
 		if not carbon then carbon = find(stanza, "{urn:xmpp:carbons:1}/forwarded/message"); end
 		stanza_direction = carbon and stanza:child_with_name("sent") and "out" or "in";
 		--session.log("debug", "mod_csi_battery_saver(%s): stanza_direction = %s, carbon = %s, stanza = %s", id, stanza_direction, carbon and "true" or "false", tostring(stanza));
 		if carbon then stanza = carbon; end
-		-- carbon copied outgoing messages aren't important (but incoming carbon copies are!)
-		if carbon and stanza_direction == "out" then return false; end
-
-		local st_type = stanza.attr.type;
-		if st_type == "headline" then
-			return false;
-		end
-
-		-- We can't check for nick in encrypted groupchat messages, so let's treat them as important
-		-- Some clients don't set a body or an empty body for encrypted messages
-
+		st_type = stanza.attr.type;
+		
+		-- headline message are always not important
+		if st_type == "headline" then return false; end
+		
+		-- chat markers (XEP-0333) are important, too, because some clients use them to update their notifications
+		if find(stanza, "{urn:xmpp:chat-markers:0}") then return true; end;
+		
+		-- carbon copied outgoing messages are important (some clients update their notifications upon receiving those) --> don't return false here
+		--if carbon and stanza_direction == "out" then return false; end
+		
+		-- We can't check for body contents in encrypted messages, so let's treat them as important
+		-- Some clients don't even set a body or an empty body for encrypted messages
+		
 		-- check omemo https://xmpp.org/extensions/inbox/omemo.html
 		if stanza:get_child("encrypted", "eu.siacs.conversations.axolotl") or stanza:get_child("encrypted", "urn:xmpp:omemo:0") then return true; end
-
+		
 		-- check xep27 pgp https://xmpp.org/extensions/xep-0027.html
 		if stanza:get_child("x", "jabber:x:encrypted") then return true; end
-
+		
 		-- check xep373 pgp (OX) https://xmpp.org/extensions/xep-0373.html
 		if stanza:get_child("openpgp", "urn:xmpp:openpgp:0") then return true; end
-
+		
 		local body = stanza:get_child_text("body");
 		if st_type == "groupchat" then
 			if stanza:get_child_text("subject") then return true; end