Signals: an admin chooses whether the server's TypeSafe key pays for everyone (#271)
With signals_on_server set and TYPESAFE_KEY present, the judge asks Jev about everyone's Signals on the server's key; otherwise each person turns Signals on in Settings with a key of their own, which is now checked with TypeSafe before it is saved. The Signals folder shows only when they are on. The browser suite's daemon inherited the shell's TYPESAFE_KEY, so fixture feeds were sent to the real TypeSafe to be categorised; it is blanked now, and an empty key counts as none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,11 @@ http.createServer((req, res) => {
|
||||
let body = '';
|
||||
req.on('data', c => { body += c; });
|
||||
req.on('end', () => {
|
||||
// As TypeSafe answers a key it does not know (#271).
|
||||
if (req.headers.authorization === 'Bearer bad-key') {
|
||||
res.writeHead(401, { 'content-type': 'application/json' }).end('{"detail":"invalid api key"}');
|
||||
return;
|
||||
}
|
||||
const { state, questions } = JSON.parse(body);
|
||||
if (Object.values(questions).some(q => typeof q.criteria !== 'object')) {
|
||||
res.writeHead(422, { 'content-type': 'application/json' }).end('{"detail":"criteria should be an object"}');
|
||||
@@ -21,7 +26,8 @@ http.createServer((req, res) => {
|
||||
const title = String(state).toLowerCase();
|
||||
const answers = {};
|
||||
for (const [id, q] of Object.entries(questions)) {
|
||||
const words = /described by these words: ([^.]*)\./.exec(q.instructions)[1].split(', ');
|
||||
// A key's check asks about no Signal's words.
|
||||
const words = /described by these words: ([^.]*)\./.exec(q.instructions)?.[1].split(', ') ?? [];
|
||||
answers[id] = { noul: words.some(w => title.includes(w.toLowerCase())) ? 0.9 : 0.1 };
|
||||
}
|
||||
res.writeHead(200, { 'content-type': 'application/json' }).end(JSON.stringify({ answers }));
|
||||
|
||||
Reference in New Issue
Block a user