Comparison

mod_csi_battery_saver/mod_csi_battery_saver.lua @ 2946:dfac28504e86

mod_csi_battery_saver: Remove whitespace only lines
author Michel Le Bihan <michel@lebihan.pl>
date Fri, 23 Mar 2018 22:38:46 +0100
parent 2757:595d9d68fd11
child 3109:75930e4c2478
comparison
equal deleted inserted replaced
2945:ec7f9c8f2a5f 2946:dfac28504e86
114 if not carbon then carbon = find(stanza, "{urn:xmpp:carbons:1}/forwarded/message"); end 114 if not carbon then carbon = find(stanza, "{urn:xmpp:carbons:1}/forwarded/message"); end
115 stanza_direction = carbon and stanza:child_with_name("sent") and "out" or "in"; 115 stanza_direction = carbon and stanza:child_with_name("sent") and "out" or "in";
116 --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)); 116 --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));
117 if carbon then stanza = carbon; end 117 if carbon then stanza = carbon; end
118 st_type = stanza.attr.type; 118 st_type = stanza.attr.type;
119 119
120 -- headline message are always not important 120 -- headline message are always not important
121 if st_type == "headline" then return false; end 121 if st_type == "headline" then return false; end
122 122
123 -- chat markers (XEP-0333) are important, too, because some clients use them to update their notifications 123 -- chat markers (XEP-0333) are important, too, because some clients use them to update their notifications
124 if find(stanza, "{urn:xmpp:chat-markers:0}") then return true; end; 124 if find(stanza, "{urn:xmpp:chat-markers:0}") then return true; end;
125 125
126 -- carbon copied outgoing messages are important (some clients update their notifications upon receiving those) --> don't return false here 126 -- carbon copied outgoing messages are important (some clients update their notifications upon receiving those) --> don't return false here
127 --if carbon and stanza_direction == "out" then return false; end 127 --if carbon and stanza_direction == "out" then return false; end
128 128
129 -- We can't check for body contents in encrypted messages, so let's treat them as important 129 -- We can't check for body contents in encrypted messages, so let's treat them as important
130 -- Some clients don't even set a body or an empty body for encrypted messages 130 -- Some clients don't even set a body or an empty body for encrypted messages
131 131
132 -- check omemo https://xmpp.org/extensions/inbox/omemo.html 132 -- check omemo https://xmpp.org/extensions/inbox/omemo.html
133 if stanza:get_child("encrypted", "eu.siacs.conversations.axolotl") or stanza:get_child("encrypted", "urn:xmpp:omemo:0") then return true; end 133 if stanza:get_child("encrypted", "eu.siacs.conversations.axolotl") or stanza:get_child("encrypted", "urn:xmpp:omemo:0") then return true; end
134 134
135 -- check xep27 pgp https://xmpp.org/extensions/xep-0027.html 135 -- check xep27 pgp https://xmpp.org/extensions/xep-0027.html
136 if stanza:get_child("x", "jabber:x:encrypted") then return true; end 136 if stanza:get_child("x", "jabber:x:encrypted") then return true; end
137 137
138 -- check xep373 pgp (OX) https://xmpp.org/extensions/xep-0373.html 138 -- check xep373 pgp (OX) https://xmpp.org/extensions/xep-0373.html
139 if stanza:get_child("openpgp", "urn:xmpp:openpgp:0") then return true; end 139 if stanza:get_child("openpgp", "urn:xmpp:openpgp:0") then return true; end
140 140
141 local body = stanza:get_child_text("body"); 141 local body = stanza:get_child_text("body");
142 if st_type == "groupchat" then 142 if st_type == "groupchat" then
143 if stanza:get_child_text("subject") then return true; end 143 if stanza:get_child_text("subject") then return true; end
144 if body == nil or body == "" then return false; end 144 if body == nil or body == "" then return false; end
145 -- body contains text, let's see if we want to process it further 145 -- body contains text, let's see if we want to process it further