patches from chongqing site

This commit is contained in:
undefined committed 2025-12-02 00:28:58 +08:00
1 parent b530a8dc00
commit 956631680b
16 files changed
+146 -85

No files matched your search

+6 -3
View File
@@ -485,8 +485,11 @@ export class ContestCodeHandler extends Handler {
async get(domainId: string, tid: ObjectId, all: boolean) {
await this.limitRate('contest_code', 60, 10);
const [tdoc, tsdocs] = await contest.getAndListStatus(domainId, tid);
if (!this.user.own(tdoc) && !this.user.hasPriv(PRIV.PRIV_READ_RECORD_CODE)) {
this.checkPerm(PERM.PERM_READ_RECORD_CODE);
if (!this.user.own(tdoc)) {
if (!this.user.hasPriv(PRIV.PRIV_READ_RECORD_CODE)) {
this.checkPerm(PERM.PERM_READ_RECORD_CODE);
}
if (!contest.isDone(tdoc)) throw new ContestNotEndedError(domainId, tid);
}
if (!contest.canShowRecord.call(this, tdoc as any, true)) {
throw new PermissionError(PERM.PERM_VIEW_CONTEST_HIDDEN_SCOREBOARD);
@@ -754,7 +757,7 @@ export class ContestBalloonHandler extends ContestManagementBaseHandler {
async postDone(domainId: string, tid: ObjectId, bid: ObjectId) {
const balloon = await contest.getBalloon(domainId, tid, bid);
if (!balloon) throw new ValidationError('balloon');
if (balloon.sent) throw new ValidationError('balloon', null, 'Balloon already sent');
if (balloon.sent) throw new ValidationError('Balloon already sent');
await contest.updateBalloon(domainId, tid, bid, { sent: this.user._id, sentAt: new Date() });
this.back();
}
+4 -6
View File
@@ -124,15 +124,13 @@ class HomeworkDetailHandler extends Handler {
await contest.setStatus(domainId, tid, this.user._id, { startAt: new Date() });
tsdoc.startAt = new Date();
}
for (const pdetail of tsdoc.journal || []) {
const valid = (tsdoc.journal || []).filter((p) => this.tdoc.pids.includes(p.pid));
for (const pdetail of valid) {
psdict[pdetail.pid] = pdetail;
rdict[pdetail.rid] = { _id: pdetail.rid };
}
if (contest.canShowSelfRecord.call(this, this.tdoc) && tsdoc.journal) {
rdict = await record.getList(
domainId,
tsdoc.journal.map((pdetail) => pdetail.rid),
);
if (contest.canShowSelfRecord.call(this, this.tdoc) && valid.length) {
rdict = await record.getList(domainId, valid.map((pdetail) => pdetail.rid));
}
}
Object.assign(this.response.body, { pdict, psdict, rdict });
+1
View File
@@ -331,6 +331,7 @@ class RecordMainConnectionHandler extends ConnectionHandler {
if (rdoc.domainId !== this.args.domainId) return;
if (!this.pretest && typeof rdoc.input === 'string') return;
if (!this.all) {
if (!rdoc.contest && this.tid) return;
if (rdoc.contest && ![this.tid, '000000000000000000000000'].includes(rdoc.contest.toString())) return;
if (this.tid && rdoc.contest?.toString() !== '0'.repeat(24)) {
if (rdoc.uid !== this.user._id && !contest.canShowRecord.call(this, this.tdoc, true)) return;