Mercurial > prosody-modules
comparison mod_cloud_notify/mod_cloud_notify.lua @ 5057:c728e82265a7
mod_cloud_notify: Improve logging for various error cases
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 24 Sep 2022 08:28:07 +0100 |
parents | 00e8cc6860cb |
children | fd6cb4365438 |
comparison
equal
deleted
inserted
replaced
5056:2583bd7eb5d1 | 5057:c728e82265a7 |
---|---|
77 function handle_push_error(event) | 77 function handle_push_error(event) |
78 local stanza = event.stanza; | 78 local stanza = event.stanza; |
79 local error_type, condition, error_text = stanza:get_error(); | 79 local error_type, condition, error_text = stanza:get_error(); |
80 local node = id2node[stanza.attr.id]; | 80 local node = id2node[stanza.attr.id]; |
81 local identifier = id2identifier[stanza.attr.id]; | 81 local identifier = id2identifier[stanza.attr.id]; |
82 if node == nil then return false; end -- unknown stanza? Ignore for now! | 82 if node == nil then |
83 module:log("warn", "Received push error with unrecognised id: %s", stanza.attr.id); | |
84 return false; -- unknown stanza? Ignore for now! | |
85 end | |
83 local from = stanza.attr.from; | 86 local from = stanza.attr.from; |
84 local user_push_services = push_store:get(node); | 87 local user_push_services = push_store:get(node); |
85 local changed = false; | 88 local found, changed = false, false; |
86 | 89 |
87 for push_identifier, _ in pairs(user_push_services) do | 90 for push_identifier, _ in pairs(user_push_services) do |
88 if push_identifier == identifier then | 91 if push_identifier == identifier then |
92 found = true; | |
89 if user_push_services[push_identifier] and user_push_services[push_identifier].jid == from and error_type ~= "wait" then | 93 if user_push_services[push_identifier] and user_push_services[push_identifier].jid == from and error_type ~= "wait" then |
90 push_errors[push_identifier] = push_errors[push_identifier] + 1; | 94 push_errors[push_identifier] = push_errors[push_identifier] + 1; |
91 module:log("info", "Got error <%s:%s:%s> for identifier '%s': " | 95 module:log("info", "Got error <%s:%s:%s> for identifier '%s': " |
92 .."error count for this identifier is now at %s", error_type, condition, error_text or "", push_identifier, | 96 .."error count for this identifier is now at %s", error_type, condition, error_text or "", push_identifier, |
93 tostring(push_errors[push_identifier])); | 97 tostring(push_errors[push_identifier])); |
120 id2identifier[stanza.attr.id] = nil; | 124 id2identifier[stanza.attr.id] = nil; |
121 end | 125 end |
122 elseif user_push_services[push_identifier] and user_push_services[push_identifier].jid == from and error_type == "wait" then | 126 elseif user_push_services[push_identifier] and user_push_services[push_identifier].jid == from and error_type == "wait" then |
123 module:log("debug", "Got error <%s:%s:%s> for identifier '%s': " | 127 module:log("debug", "Got error <%s:%s:%s> for identifier '%s': " |
124 .."NOT increasing error count for this identifier", error_type, condition, error_text or "", push_identifier); | 128 .."NOT increasing error count for this identifier", error_type, condition, error_text or "", push_identifier); |
129 else | |
130 module:log("debug", "Unhandled push error <%s:%s:%s> from %s for identifier '%s'", | |
131 error_type, condition, error_text or "", from, push_identifier | |
132 ); | |
125 end | 133 end |
126 end | 134 end |
127 end | 135 end |
128 if changed then | 136 if changed then |
129 push_store:flush_to_disk(node); | 137 push_store:flush_to_disk(node); |
138 elseif not found then | |
139 module:log("warn", "Unable to find matching registration for push error <%s:%s:%s> from %s", error_type, condition, error_text or "", from); | |
130 end | 140 end |
131 return true; | 141 return true; |
132 end | 142 end |
133 | 143 |
134 function handle_push_success(event) | 144 function handle_push_success(event) |