changeset 4366:83370df0ce4a

mod_http_admin_api: do not report OMEMO as ok if no devices exist
author Jonas Schäfer <jonas@wielicki.name>
date Thu, 21 Jan 2021 16:18:14 +0100
parents f975a4d31f35
children 33f82988d7a9
files mod_http_admin_api/mod_http_admin_api.lua
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_http_admin_api/mod_http_admin_api.lua	Thu Jan 21 16:13:29 2021 +0100
+++ b/mod_http_admin_api/mod_http_admin_api.lua	Thu Jan 21 16:18:14 2021 +0100
@@ -202,6 +202,7 @@
 
 local function get_user_omemo_info(username)
 	local everything_valid = true;
+	local any_device = false;
 	local omemo_status = {};
 	local omemo_devices;
 	local pep_service = mod_pep.get_pep_service(username);
@@ -213,6 +214,7 @@
 		if device_list then
 			omemo_devices = {};
 			for device_entry in device_list:childtags("device") do
+				any_device = true;
 				local device_info = {};
 				local device_id = tonumber(device_entry.attr.id or "");
 				if device_id then
@@ -256,7 +258,7 @@
 			end
 		end
 	end
-	omemo_status.valid = everything_valid;
+	omemo_status.valid = everything_valid and any_device;
 	return {
 		status = omemo_status;
 		devices = omemo_devices;