diff 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
line wrap: on
line diff
--- a/mod_debug_omemo/mod_debug_omemo.lua	Mon Sep 13 21:45:20 2021 +0200
+++ b/mod_debug_omemo/mod_debug_omemo.lua	Mon Sep 13 21:47:01 2021 +0200
@@ -167,12 +167,16 @@
 	};
 
 	data.omemo.devices = {};
-	for _, device_info in ipairs(user_omemo_status.devices) do
-		data.omemo.devices[("%d"):format(device_info.id)] = {
-			status = device_info.valid and "OK" or "Problem";
-			bundle = device_info.have_bundle and "Published" or "Missing";
-			access_model = access_model_text[device_info.bundle_config and device_info.bundle_config.access_model or nil];
-		};
+	if user_omemo_status.devices then
+		for _, device_info in ipairs(user_omemo_status.devices) do
+			data.omemo.devices[("%d"):format(device_info.id)] = {
+				status = device_info.valid and "OK" or "Problem";
+				bundle = device_info.have_bundle and "Published" or "Missing";
+				access_model = access_model_text[device_info.bundle_config and device_info.bundle_config.access_model or nil];
+			};
+		end
+	else
+		data.omemo.devices[false] = { status = "No devices", };
 	end
 
 	event.response.headers.content_type = "text/html; charset=utf-8";