From c81525ffc4b98f1ae6d77b43057549618d920306 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 10 May 2022 13:13:02 +0530 Subject: [PATCH] checkup: complain if public instance don't provide description & location --- server.js | 1 + www/checkup/main.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/server.js b/server.js index a9bebabf4..3830a1fbc 100644 --- a/server.js +++ b/server.js @@ -237,6 +237,7 @@ var serveConfig = makeRouteCache(function (host) { enableEmbedding: Env.enableEmbedding, fileHost: Env.fileHost, shouldUpdateNode: Env.shouldUpdateNode || undefined, + listMyInstance: Env.listMyInstance, }, null, '\t'), '});' ].join(';\n') diff --git a/www/checkup/main.js b/www/checkup/main.js index a71e2c3f0..ceede953c 100644 --- a/www/checkup/main.js +++ b/www/checkup/main.js @@ -1385,6 +1385,36 @@ define([ }); }); + assert(function (cb, msg) { + if (!ApiConfig.listMyInstance) { return void cb(true); } + msg.appendChild(h('span', [ + "The administrators of this instance have opted in to inclusion in ", + link('https://cryptpad.org/instances/', 'the public instance directory'), + ' but have not configured at least one of the expected ', + code('description'), + ' or ', + code('location'), + ' text fields via the instance admin panel.', + ])); + var expected = [ + 'description', + 'location', + //'name', + // 'notice', + ]; + + var url = '/api/instance'; + require([ + `optional!${url}`, + ], function (Instance) { + var good = expected.every(function (k) { + var val = Instance[k]; + return (val && typeof(val) === 'object' && typeof(val.default) === 'string' && val.default.trim()); + }); + return void cb(good || Instance); + }); + }); + var serverToken; Tools.common_xhr('/', function (xhr) { serverToken = xhr.getResponseHeader('server');