MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / prepare

Method prepare

packages/hydrooj/src/handler/problem.ts:554–566  ·  view source on GitHub ↗
(domainId: string, rid: ObjectId, tid?: ObjectId)

Source from the content-addressed store, hash-verified

552 @param('rid', Types.ObjectId)
553 @param('tid', Types.ObjectId, true)
554 async prepare(domainId: string, rid: ObjectId, tid?: ObjectId) {
555 if (typeof this.pdoc.config !== 'object' || !this.pdoc.config.hackable) throw new HackFailedError('This problem is not hackable.');
556 this.rdoc = await record.get(domainId, rid);
557 if (!this.rdoc || this.rdoc.pid !== this.pdoc.docId
558 || this.rdoc.contest?.toString() !== tid?.toString()) throw new RecordNotFoundError(domainId, rid);
559 if (tid) {
560 if (this.tdoc.rule !== 'codeforces') throw new HackFailedError('This contest is not hackable.');
561 if (!contest.isOngoing(this.tdoc, this.tsdoc)) throw new ContestNotLiveError(this.tdoc.docId);
562 }
563 if (this.rdoc.uid === this.user._id) throw new HackFailedError('You cannot hack your own submission');
564 if (this.psdoc?.status !== STATUS.STATUS_ACCEPTED) throw new HackFailedError('You must accept this problem before hacking.');
565 if (this.rdoc.status !== STATUS.STATUS_ACCEPTED) throw new HackFailedError('You cannot hack a unsuccessful submission.');
566 }
567
568 async get() {
569 this.response.template = 'problem_hack.html';

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected