Merge branch 'master' into develop

This commit is contained in:
undefined committed 2021-05-02 14:31:33 +08:00
commit 0454acdbf9
13 files changed
+29 -18

No files matched your search

+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "@hydrooj/hydrojudge", "name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js", "bin": "bin/hydrojudge.js",
"version": "2.5.16", "version": "2.5.18",
"main": "package.json", "main": "package.json",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git", "repository": "https://github.com/hydro-dev/Hydro.git",
"dependencies": { "dependencies": {
"@hydrooj/utils": "^1.0.8", "@hydrooj/utils": "^1.0.9",
"adm-zip": "^0.5.5", "adm-zip": "^0.5.5",
"axios": "^0.21.1", "axios": "^0.21.1",
"bson": "^4.3.0", "bson": "^4.3.0",
+10 -5
View File
@@ -104,8 +104,9 @@ async function read0(folder: string, files: string[], checkFile, cfg) {
return config; return config;
} }
async function read1(folder: string, files: string[], checkFile, cfg) { async function read1(folder: string, files: string[], checkFile, cfg, rst) {
const subtask = {}; const subtask = {};
for (const s of rst.subtasks) if (s.id) subtask[s.id] = s;
const subtasks = []; const subtasks = [];
for (const file of files) { for (const file of files) {
for (const REG of RE1) { for (const REG of RE1) {
@@ -150,7 +151,7 @@ async function read1(folder: string, files: string[], checkFile, cfg) {
return config; return config;
} }
async function readAutoCases(folder, { next }, cfg) { async function readAutoCases(folder, { next }, cfg, rst) {
const config = { const config = {
checker_type: 'default', checker_type: 'default',
count: 0, count: 0,
@@ -170,7 +171,7 @@ async function readAutoCases(folder, { next }, cfg) {
files.push(...outputs.map((i) => `output/${i}`)); files.push(...outputs.map((i) => `output/${i}`));
} }
let result = await read0(folder, files, checkFile, cfg); let result = await read0(folder, files, checkFile, cfg);
if (!result.count) result = await read1(folder, files, checkFile, cfg); if (!result.count) result = await read1(folder, files, checkFile, cfg, rst);
Object.assign(config, result); Object.assign(config, result);
next({ message: { message: 'Found {0} testcases.', params: [config.count] } }); next({ message: { message: 'Found {0} testcases.', params: [config.count] } });
} catch (e) { } catch (e) {
@@ -214,8 +215,12 @@ export default async function readCases(folder: string, cfg: Record<string, any>
} catch (e) { } catch (e) {
throw changeErrorType(e, FormatError); throw changeErrorType(e, FormatError);
} }
if (!(result.outputs?.length || result.subtasks.length)) { let auto = !result.outputs?.length;
const c = await readAutoCases(folder, args, config); if (!result.subtasks.length) {
auto = !Math.sum(result.subtasks.map((subtask) => subtask.cases.length));
}
if (auto) {
const c = await readAutoCases(folder, args, config, result);
result.subtasks = c.subtasks; result.subtasks = c.subtasks;
result.count = c.count; result.count = c.count;
} }
+1 -1
View File
@@ -167,7 +167,7 @@ export default class Hydro {
constructor(config) { constructor(config) {
this.config = config; this.config = config;
this.config.detail = this.config.detail || true; this.config.detail = this.config.detail ?? true;
this.config.cookie = this.config.cookie || ''; this.config.cookie = this.config.cookie || '';
this.config.last_update_at = this.config.last_update_at || 0; this.config.last_update_at = this.config.last_update_at || 0;
if (!this.config.server_url.startsWith('http')) this.config.server_url = `http://${this.config.server_url}`; if (!this.config.server_url.startsWith('http')) this.config.server_url = `http://${this.config.server_url}`;
+1 -1
View File
@@ -173,7 +173,7 @@ export default class VJ4 {
constructor(config) { constructor(config) {
this.config = config; this.config = config;
this.config.detail = this.config.detail || true; this.config.detail = this.config.detail ?? true;
this.config.cookie = this.config.cookie || ''; this.config.cookie = this.config.cookie || '';
this.config.last_update_at = this.config.last_update_at || 0; this.config.last_update_at = this.config.last_update_at || 0;
if (!this.config.server_url.startsWith('http')) this.config.server_url = `http://${this.config.server_url}`; if (!this.config.server_url.startsWith('http')) this.config.server_url = `http://${this.config.server_url}`;
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.23.30", "version": "2.23.31",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "dist/loader.js", "main": "dist/loader.js",
"typings": "dist/loader.d.ts", "typings": "dist/loader.d.ts",
+1 -1
View File
@@ -219,7 +219,7 @@ class DomainJoinApplicationsHandler extends ManageHandler {
if (!this.response.body.joinSettings) { if (!this.response.body.joinSettings) {
delete this.response.body.expirations[domain.JOIN_EXPIRATION_KEEP_CURRENT]; delete this.response.body.expirations[domain.JOIN_EXPIRATION_KEEP_CURRENT];
} }
this.response.body.url_prefix = system.get('server.url'); this.response.body.url_prefix = (this.domain.host || [])[0] || system.get('server.url');
this.response.body.path = [ this.response.body.path = [
['Hydro', 'homepage'], ['Hydro', 'homepage'],
['domain', null], ['domain', null],
+1 -1
View File
@@ -168,7 +168,7 @@ class HomeSecurityHandler extends Handler {
const m = await this.renderHTML('user_changemail_mail.html', { const m = await this.renderHTML('user_changemail_mail.html', {
path: `home/changeMail/${code}`, path: `home/changeMail/${code}`,
uname: this.user.uname, uname: this.user.uname,
url_prefix: system.get('server.url'), url_prefix: (this.domain.host || [])[0] || system.get('server.url'),
}); });
await mail.sendMail(email, 'Change Email', 'user_changemail_mail', m); await mail.sendMail(email, 'Change Email', 'user_changemail_mail', m);
this.response.template = 'user_changemail_mail_sent.html'; this.response.template = 'user_changemail_mail_sent.html';
+2 -2
View File
@@ -79,7 +79,7 @@ export class UserRegisterHandler extends Handler {
if (system.get('smtp.user')) { if (system.get('smtp.user')) {
const m = await this.renderHTML('user_register_mail.html', { const m = await this.renderHTML('user_register_mail.html', {
path: `register/${t[0]}`, path: `register/${t[0]}`,
url_prefix: system.get('server.url'), url_prefix: (this.domain.host || [])[0] || system.get('server.url'),
}); });
await sendMail(mail, 'Sign Up', 'user_register_mail', m); await sendMail(mail, 'Sign Up', 'user_register_mail', m);
this.response.template = 'user_register_mail_sent.html'; this.response.template = 'user_register_mail_sent.html';
@@ -146,7 +146,7 @@ class UserLostPassHandler extends Handler {
); );
const m = await this.renderHTML('user_lostpass_mail.html', { const m = await this.renderHTML('user_lostpass_mail.html', {
url: `lostpass/${tid}`, url: `lostpass/${tid}`,
url_prefix: system.get('server.url'), url_prefix: this.domain.host || system.get('server.url'),
uname: udoc.uname, uname: udoc.uname,
}); });
await sendMail(mail, 'Lost Password', 'user_lostpass_mail', m); await sendMail(mail, 'Lost Password', 'user_lostpass_mail', m);
+1 -1
View File
@@ -307,7 +307,7 @@ export interface DomainDoc extends Record<string, any> {
avatar: string, avatar: string,
bulletin: string, bulletin: string,
_join?: any, _join?: any,
host?: string, host?: string[],
} }
// Message // Message
+1 -1
View File
@@ -5,7 +5,7 @@ import user from './model/user';
import problem, { Field, Pdoc } from './model/problem'; import problem, { Field, Pdoc } from './model/problem';
export async function iterateAllDomain(cb: (ddoc: DomainDoc, current?: number, total?: number) => Promise<any>) { export async function iterateAllDomain(cb: (ddoc: DomainDoc, current?: number, total?: number) => Promise<any>) {
const ddocs = await domain.getMulti().project({ _id: 1, owner: 1 }).toArray(); const ddocs = await domain.getMulti().toArray();
for (const i in ddocs) await cb(ddocs[i], +i, ddocs.length); for (const i in ddocs) await cb(ddocs[i], +i, ddocs.length);
} }
+6
View File
@@ -311,6 +311,12 @@ const scripts: UpgradeScript[] = [
await db.collection('oplog').updateMany({}, { $set: { type: 'delete', operateIp: '127.0.0.1' } }); await db.collection('oplog').updateMany({}, { $set: { type: 'delete', operateIp: '127.0.0.1' } });
return true; return true;
}, },
async function _24_25() {
await iterateAllDomain(async (ddoc) => {
if (typeof ddoc.host === 'string') await domain.edit(ddoc._id, { host: [ddoc.host] });
});
return true;
},
]; ];
export default scripts; export default scripts;
+1 -1
View File
@@ -51,7 +51,7 @@ export default async function readYamlCases(cfg: Record<string, any> = {}, check
} else if (cfg.subtasks) { } else if (cfg.subtasks) {
for (const subtask of cfg.subtasks) { for (const subtask of cfg.subtasks) {
const cases = []; const cases = [];
for (const c of subtask.cases) { for (const c of subtask.cases || []) {
config.count++; config.count++;
cases.push({ cases.push({
input: c.input ? checkFile(c.input, 'Cannot find input file {0}.') : '/dev/null', input: c.input ? checkFile(c.input, 'Cannot find input file {0}.') : '/dev/null',
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@hydrooj/utils", "name": "@hydrooj/utils",
"version": "1.0.8", "version": "1.0.9",
"description": "hydrooj utils", "description": "hydrooj utils",
"main": "package.json", "main": "package.json",
"repository": "https://github.com/hydro-dev/Hydro.git", "repository": "https://github.com/hydro-dev/Hydro.git",