comparison mod_csi_battery_saver/mod_csi_battery_saver.lua @ 5802:f6a2602129c8

mod_csi_battery_saver: mark some presences as important
author tmolitor <thilo@eightysoft.de>
date Wed, 03 Jan 2024 07:53:55 +0100
parents 889e1695e935
children
comparison
equal deleted inserted replaced
5801:73887dcb2129 5802:f6a2602129c8
86 86
87 local function is_important(stanza, session) 87 local function is_important(stanza, session)
88 local st_name = stanza and stanza.name or nil; 88 local st_name = stanza and stanza.name or nil;
89 if not st_name then return true; end -- nonzas are always important 89 if not st_name then return true; end -- nonzas are always important
90 if st_name == "presence" then 90 if st_name == "presence" then
91 -- TODO check for MUC status codes? 91 local st_type = stanza.attr.type;
92 -- subscription requests are important
93 if st_type == "subscribe" then return true; end
94 -- muc status codes are important, too
95 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc#user")
96 local muc_status = muc_x and muc_x:get_child("status") or nil
97 if muc_status and muc_status.attr.code then return true; end
92 return false; 98 return false;
93 elseif st_name == "message" then 99 elseif st_name == "message" then
94 -- unpack carbon copies 100 -- unpack carbon copies
95 local carbon, stanza_direction = extract_carbon(stanza); 101 local carbon, stanza_direction = extract_carbon(stanza);
96 --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)); 102 --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));
120 -- check xep27 pgp https://xmpp.org/extensions/xep-0027.html 126 -- check xep27 pgp https://xmpp.org/extensions/xep-0027.html
121 if stanza:get_child("x", "jabber:x:encrypted") then return true; end 127 if stanza:get_child("x", "jabber:x:encrypted") then return true; end
122 128
123 -- check xep373 pgp (OX) https://xmpp.org/extensions/xep-0373.html 129 -- check xep373 pgp (OX) https://xmpp.org/extensions/xep-0373.html
124 if stanza:get_child("openpgp", "urn:xmpp:openpgp:0") then return true; end 130 if stanza:get_child("openpgp", "urn:xmpp:openpgp:0") then return true; end
125 131
126 -- check eme 132 -- check eme
127 if stanza:get_child("encryption", "urn:xmpp:eme:0") then return true; end 133 if stanza:get_child("encryption", "urn:xmpp:eme:0") then return true; end
128 134
129 local body = stanza:get_child_text("body"); 135 local body = stanza:get_child_text("body");
130 if st_type == "groupchat" then 136 if st_type == "groupchat" then