changeset 3786:58e484426d13

mod_nodeinfo2: Fix traceback on non-existing data
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 29 Dec 2019 23:41:32 +0100 (2019-12-29)
parents 6273705e3830
children 28deb30a5272
files mod_nodeinfo2/mod_nodeinfo2.lua
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_nodeinfo2/mod_nodeinfo2.lua	Sun Dec 29 22:09:58 2019 +0100
+++ b/mod_nodeinfo2/mod_nodeinfo2.lua	Sun Dec 29 23:41:32 2019 +0100
@@ -38,7 +38,7 @@
 	week_users = nil;
 end
 
-local data = main_store:get("nodeinfo2");
+local data = main_store:get("nodeinfo2") or { message_count = 0 };
 
 module:provides("http", {
 	default_path = "/.well-known/x-nodeinfo2";
@@ -48,7 +48,7 @@
 			for stat, _ in pairs(stats) do
 				if stat == "/"..module.host.."/mod_measure_message_e2ee/message:rate" then
 					local new_message_count = extras[stat].total;
-					if not data or new_message_count ~= data.message_count then
+					if new_message_count ~= data.message_count then
 						data = { message_count = new_message_count };
 						main_store:set("nodeinfo2", data);
 					end