mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
patches from zhengzhou site
This commit is contained in:
19 files changed
+80
-40
No files matched your search
@@ -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 }),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user