Mercurial > prosody-modules
comparison mod_debug_omemo/mod_debug_omemo.lua @ 4686:76af816739f3
mod_debug_omemo: Fix traceback in case of zero devices
Turns out ipairs(nil) in Lua 5.4 does not throw until the first
iterator.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 13 Sep 2021 21:47:01 +0200 |
parents | 07b6f444bafb |
children | 41ddb782320c |
comparison
equal
deleted
inserted
replaced
4685:07b6f444bafb | 4686:76af816739f3 |
---|---|
165 sender_id = sender_id; | 165 sender_id = sender_id; |
166 status = user_omemo_status.status.valid and "no known issues" or "problems"; | 166 status = user_omemo_status.status.valid and "no known issues" or "problems"; |
167 }; | 167 }; |
168 | 168 |
169 data.omemo.devices = {}; | 169 data.omemo.devices = {}; |
170 for _, device_info in ipairs(user_omemo_status.devices) do | 170 if user_omemo_status.devices then |
171 data.omemo.devices[("%d"):format(device_info.id)] = { | 171 for _, device_info in ipairs(user_omemo_status.devices) do |
172 status = device_info.valid and "OK" or "Problem"; | 172 data.omemo.devices[("%d"):format(device_info.id)] = { |
173 bundle = device_info.have_bundle and "Published" or "Missing"; | 173 status = device_info.valid and "OK" or "Problem"; |
174 access_model = access_model_text[device_info.bundle_config and device_info.bundle_config.access_model or nil]; | 174 bundle = device_info.have_bundle and "Published" or "Missing"; |
175 }; | 175 access_model = access_model_text[device_info.bundle_config and device_info.bundle_config.access_model or nil]; |
176 }; | |
177 end | |
178 else | |
179 data.omemo.devices[false] = { status = "No devices", }; | |
176 end | 180 end |
177 | 181 |
178 event.response.headers.content_type = "text/html; charset=utf-8"; | 182 event.response.headers.content_type = "text/html; charset=utf-8"; |
179 return render_html_template(tpl, data); | 183 return render_html_template(tpl, data); |
180 end | 184 end |