patches from zhengzhou site

This commit is contained in:
undefined committed 2025-11-24 15:45:11 +08:00
1 parent ded00efa60
commit e6c22d6f81
19 files changed
+80 -40

No files matched your search

+4 -4
View File
@@ -24,7 +24,7 @@
"@mongodb-js/saslprep": "^1.3.2",
"@simplewebauthn/server": "13.2.2",
"@undefined-moe/require-resolve-hook": "^1.1.0",
"@zip.js/zip.js": "^2.8.10",
"@zip.js/zip.js": "^2.8.11",
"adm-zip": "0.5.16",
"cac": "^6.7.14",
"cordis": "4.0.0-beta.5",
@@ -37,14 +37,14 @@
"koa-static-cache": "^5.1.4",
"lodash": "^4.17.21",
"lru-cache": "^11.2.2",
"mime-types": "^3.0.1",
"mime-types": "^3.0.2",
"moment-timezone": "^0.6.0",
"mongodb": "^7.0.0",
"mongodb-uri": "^0.9.7",
"nanoid": "^5.1.6",
"nodemailer": "^7.0.10",
"notp": "^2.0.3",
"p-queue": "^9.0.0",
"p-queue": "^9.0.1",
"sanitize-filename": "^1.6.3",
"schemastery": "^3.17.2",
"semver": "^7.7.3",
@@ -60,7 +60,7 @@
"@types/fs-extra": "^11.0.4",
"@types/js-yaml": "^4.0.9",
"@types/koa-static-cache": "^5.1.4",
"@types/lodash": "^4.17.20",
"@types/lodash": "^4.17.21",
"@types/mime-types": "^3.0.1",
"@types/mongodb-uri": "^0.9.4",
"@types/nodemailer": "^7.0.4",
+1 -1
View File
@@ -333,7 +333,7 @@ export class ContestProblemListHandler extends ContestDetailBaseHandler {
await this.limitRate('add_discussion', 3600, 60);
await contest.addClarification(domainId, tid, this.user._id, content, this.request.ip, subject);
if (!this.user.own(this.tdoc)) {
await message.send(1, this.tdoc.maintainer.concat(this.tdoc.owner), JSON.stringify({
await message.send(1, (this.tdoc.maintainer || []).concat(this.tdoc.owner), JSON.stringify({
message: 'Contest {0} has a new clarification about {1}, please go to contest clarifications page to reply.',
params: [this.tdoc.title, subject > 0 ? `#${this.tdoc.pids.indexOf(subject) + 1}` : 'the contest'],
url: this.url('contest_clarification', { tid }),
+3 -3
View File
@@ -333,8 +333,8 @@ class RecordMainConnectionHandler extends ConnectionHandler {
if (!this.all) {
if (rdoc.contest && ![this.tid, '000000000000000000000000'].includes(rdoc.contest.toString())) return;
if (this.tid && rdoc.contest?.toString() !== '0'.repeat(24)) {
if (contest.isLocked(this.tdoc) && !this.pretest) return;
if (!contest.canShowSelfRecord.call(this, this.tdoc, true)) return;
if (rdoc.uid !== this.user._id && !contest.canShowRecord.call(this, this.tdoc, true)) return;
if (rdoc.uid === this.user._id && !contest.canShowSelfRecord.call(this, this.tdoc, true)) return;
}
}
}
@@ -345,7 +345,7 @@ class RecordMainConnectionHandler extends ConnectionHandler {
user.getById(this.args.domainId, rdoc.uid),
problem.get(rdoc.domainId, rdoc.pid),
]);
const tdoc = this.tid ? this.tdoc || await contest.get(rdoc.domainId, new ObjectId(this.tid)) : null;
const tdoc = this.tid ? this.tdoc : null;
if (pdoc && !rdoc.contest) {
if (!problem.canViewBy(pdoc, this.user)) pdoc = null;
if (!this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)) pdoc = null;
+1
View File
@@ -213,6 +213,7 @@ export type RecordDoc = {
[K in keyof RecordPayload]: K extends 'hackTarget' | 'contest' ? ObjectId : RecordPayload[K];
} & {
_id: ObjectId;
notify?: boolean;
};
export interface RecordHistoryDoc extends RecordJudgeInfo {
+12 -1
View File
@@ -4,7 +4,7 @@ import {
Filter, FindOptions, MatchKeysAndValues,
ObjectId, OnlyFieldsOfType, PushOperator, UpdateFilter,
} from 'mongodb';
import { ProblemConfigFile } from '@hydrooj/common';
import { ProblemConfigFile, STATUS_TEXTS } from '@hydrooj/common';
import { Context } from '../context';
import { ProblemNotFoundError } from '../error';
import { JudgeMeta, RecordDoc } from '../interface';
@@ -13,6 +13,7 @@ import { MaybeArray, NumberKeys } from '../typeutils';
import { ArgMethod, buildProjection, Time } from '../utils';
import { STATUS } from './builtin';
import DomainModel from './domain';
import MessageModel from './message';
import problem from './problem';
import SystemModel from './system';
import task from './task';
@@ -137,6 +138,7 @@ export default class RecordModel {
files?: Record<string, string>;
hackTarget?: ObjectId;
type: 'judge' | 'rejudge' | 'pretest' | 'hack' | 'generate';
notify?: boolean;
} = { type: 'judge' },
) {
const data: RecordDoc = {
@@ -161,6 +163,7 @@ export default class RecordModel {
if (args.contest) data.contest = args.contest;
if (args.files) data.files = args.files;
if (args.hackTarget) data.hackTarget = args.hackTarget;
if (args.notify) data.notify = true;
if (args.type === 'rejudge') {
args.type = 'judge';
data.rejudged = true;
@@ -290,6 +293,14 @@ export async function apply(ctx: Context) {
]));
ctx.on('domain/delete', (domainId) => RecordModel.coll.deleteMany({ domainId }));
ctx.on('record/judge', async (rdoc, updated) => {
if (rdoc.contest?.toHexString().startsWith('0'.repeat(23))) return;
if (rdoc.notify) {
const pdoc = await Hydro.model.problem.get(rdoc.domainId, rdoc.pid);
await MessageModel.send(1, rdoc.uid, JSON.stringify({
message: 'Judge Result\n{0}: {1}',
params: [pdoc.title, STATUS_TEXTS[rdoc.status]],
}), MessageModel.FLAG_I18N);
}
if (rdoc.status === STATUS.STATUS_ACCEPTED && updated) {
if (SystemModel.get('record.statMode') === 'unique') {
await RecordModel.collStat.deleteMany({
+1 -1
View File
@@ -163,7 +163,7 @@ export class User {
}
getFields(type: 'public' | 'private' = 'public') {
const fields = ['_id', 'uname', 'mail', 'perm', 'role', 'priv', 'regat', 'loginat', 'tfa', 'authn'].concat(this._publicFields);
const fields = ['_id', 'uname', 'mail', 'perm', 'role', 'priv', 'regat', 'loginat', 'tfa', 'authn', 'avatar'].concat(this._publicFields);
return type === 'public' ? fields : fields.concat(this._privateFields);
}