| 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'; |