Software / code / prosody
Comparison
plugins/mod_csi_simple.lua @ 10807:b92afa0a4119
mod_csi_simple: Add short reasons to report
Should improve quality of debug logs
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 07 May 2020 22:56:30 +0200 |
| parent | 10806:24e2b571d29a |
| child | 10808:0d365c0ee9fe |
comparison
equal
deleted
inserted
replaced
| 10806:24e2b571d29a | 10807:b92afa0a4119 |
|---|---|
| 20 -- whitespace pings etc | 20 -- whitespace pings etc |
| 21 return true; | 21 return true; |
| 22 end | 22 end |
| 23 if stanza.attr.xmlns ~= nil then | 23 if stanza.attr.xmlns ~= nil then |
| 24 -- stream errors, stream management etc | 24 -- stream errors, stream management etc |
| 25 return true; | 25 return true, "nonza"; |
| 26 end | 26 end |
| 27 local st_name = stanza.name; | 27 local st_name = stanza.name; |
| 28 if not st_name then return false; end | 28 if not st_name then return false; end |
| 29 local st_type = stanza.attr.type; | 29 local st_type = stanza.attr.type; |
| 30 if st_name == "presence" then | 30 if st_name == "presence" then |
| 31 if st_type == nil or st_type == "unavailable" or st_name == "error" then | 31 if st_type == nil or st_type == "unavailable" or st_name == "error" then |
| 32 return false; | 32 return false, "presence update"; |
| 33 end | 33 end |
| 34 -- TODO Some MUC awareness, e.g. check for the 'this relates to you' status code | 34 -- TODO Some MUC awareness, e.g. check for the 'this relates to you' status code |
| 35 return true; | 35 return true, "subscription request"; |
| 36 elseif st_name == "message" then | 36 elseif st_name == "message" then |
| 37 if st_type == "headline" then | 37 if st_type == "headline" then |
| 38 return false; | 38 -- Headline messages are ephemeral by definition |
| 39 return false, "headline"; | |
| 39 end | 40 end |
| 40 if st_type == "error" then | 41 if st_type == "error" then |
| 41 return true; | 42 return true, "delivery failure"; |
| 42 end | 43 end |
| 43 if stanza:get_child("sent", "urn:xmpp:carbons:2") then | 44 if stanza:get_child("sent", "urn:xmpp:carbons:2") then |
| 44 return true; | 45 return true, "carbon"; |
| 45 end | 46 end |
| 46 local forwarded = stanza:find("{urn:xmpp:carbons:2}received/{urn:xmpp:forward:0}/{jabber:client}message"); | 47 local forwarded = stanza:find("{urn:xmpp:carbons:2}received/{urn:xmpp:forward:0}/{jabber:client}message"); |
| 47 if forwarded then | 48 if forwarded then |
| 48 stanza = forwarded; | 49 stanza = forwarded; |
| 49 end | 50 end |
| 50 if stanza:get_child("body") then | 51 if stanza:get_child("body") then |
| 51 return true; | 52 return true, "body"; |
| 52 end | 53 end |
| 53 if stanza:get_child("subject") then | 54 if stanza:get_child("subject") then |
| 54 return true; | 55 -- Last step of a MUC join |
| 56 return true, "subject"; | |
| 55 end | 57 end |
| 56 if stanza:get_child("encryption", "urn:xmpp:eme:0") then | 58 if stanza:get_child("encryption", "urn:xmpp:eme:0") then |
| 57 return true; | 59 -- Since we can't know what an encrypted message contains, we assume it's important |
| 60 -- XXX Experimental XEP | |
| 61 return true, "encrypted"; | |
| 58 end | 62 end |
| 59 if stanza:get_child("x", "jabber:x:conference") or stanza:find("{http://jabber.org/protocol/muc#user}x/invite") then | 63 if stanza:get_child("x", "jabber:x:conference") or stanza:find("{http://jabber.org/protocol/muc#user}x/invite") then |
| 60 return true; | 64 return true, "invite"; |
| 61 end | 65 end |
| 62 for important in important_payloads do | 66 for important in important_payloads do |
| 63 if stanza:find(important) then | 67 if stanza:find(important) then |
| 64 return true; | 68 return true; |
| 65 end | 69 end |