checkup: complain if public instance don't provide description & location

This commit is contained in:
ansuz 2022-05-10 13:13:02 +05:30
parent 071c9706af
commit c81525ffc4
2 changed files with 31 additions and 0 deletions

View file

@ -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')

View file

@ -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');