vjudge: support enableOn option

pull/428/head
undefined 2 years ago
parent 333b96f34c
commit ba187a168a

@ -1,6 +1,6 @@
{ {
"name": "@hydrooj/vjudge", "name": "@hydrooj/vjudge",
"version": "1.5.0-next.12", "version": "1.5.0-next.13",
"description": "Submit problems to remote oj", "description": "Submit problems to remote oj",
"main": "package.json", "main": "package.json",
"repository": "https://github.com/hydro-dev/Hydro.git", "repository": "https://github.com/hydro-dev/Hydro.git",

@ -11,6 +11,7 @@ export interface RemoteAccount {
query?: string; query?: string;
frozen?: string; frozen?: string;
problemLists?: string[]; problemLists?: string[];
enableOn?: string[];
} }
declare module 'hydrooj/src/interface' { declare module 'hydrooj/src/interface' {
interface Collections { interface Collections {

@ -1,4 +1,5 @@
/* eslint-disable no-await-in-loop */ /* eslint-disable no-await-in-loop */
import os from 'os';
import { sleep } from '@hydrooj/utils/lib/utils'; import { sleep } from '@hydrooj/utils/lib/utils';
import * as Judge from 'hydrooj/src/handler/judge'; import * as Judge from 'hydrooj/src/handler/judge';
import { Logger } from 'hydrooj/src/logger'; import { Logger } from 'hydrooj/src/logger';
@ -131,6 +132,7 @@ async function loadAccounts() {
const accounts = await coll.find().toArray(); const accounts = await coll.find().toArray();
for (const account of accounts) { for (const account of accounts) {
if (!providers[account.type]) continue; if (!providers[account.type]) continue;
if (account.enableOn && !account.enableOn.includes(os.hostname())) continue;
Pool[`${account.type}/${account.handle}`] = new Service(providers[account.type], account); Pool[`${account.type}/${account.handle}`] = new Service(providers[account.type], account);
} }
} }

Loading…
Cancel
Save