Merge branch 'develop' of https://github.com/hydro-dev/Hydro into develop

This commit is contained in:
undefined committed 2021-04-17 22:54:03 +08:00
commit 4ccb9f3283
7 files changed
+10 -10

No files matched your search

+1 -1
View File
@@ -261,7 +261,7 @@ class ContestProblemHandler extends ContestHandler {
if (contest.isNotStarted(this.tdoc)) throw new ContestNotLiveError(this.tdoc.docId); if (contest.isNotStarted(this.tdoc)) throw new ContestNotLiveError(this.tdoc.docId);
} }
if (!this.tdoc.pids.map((s) => s.toString()).includes(this.pdoc.docId.toString())) { if (!this.tdoc.pids.map((s) => s.toString()).includes(this.pdoc.docId.toString())) {
throw new ProblemNotFoundError(pid, this.tdoc.docId); throw new ProblemNotFoundError(domainId, this.tdoc.docId);
} }
} }
+4 -4
View File
@@ -42,17 +42,17 @@ class DiscussionHandler extends Handler {
this.checkPerm(PERM.PERM_VIEW_DISCUSSION); this.checkPerm(PERM.PERM_VIEW_DISCUSSION);
if (did) { if (did) {
this.ddoc = await discussion.get(domainId, did); this.ddoc = await discussion.get(domainId, did);
if (!this.ddoc) throw new DiscussionNotFoundError(did); if (!this.ddoc) throw new DiscussionNotFoundError(domainId, did);
type = discussion.typeDisplay[this.ddoc.parentType]; type = discussion.typeDisplay[this.ddoc.parentType];
name = this.ddoc.parentId.toString(); name = this.ddoc.parentId.toString();
if (drrid) { if (drrid) {
[this.drdoc, this.drrdoc] = await discussion.getTailReply(domainId, drid, drrid); [this.drdoc, this.drrdoc] = await discussion.getTailReply(domainId, drid, drrid);
if (!this.drrdoc) throw new DiscussionNotFoundError(drrid); if (!this.drrdoc) throw new DiscussionNotFoundError(domainId, drrid);
} else if (drid) { } else if (drid) {
this.drdoc = await discussion.getReply(domainId, drid); this.drdoc = await discussion.getReply(domainId, drid);
if (!this.drdoc) throw new DiscussionNotFoundError(drid); if (!this.drdoc) throw new DiscussionNotFoundError(domainId, drid);
if (!this.drdoc.parentId.equals(this.ddoc._id)) { if (!this.drdoc.parentId.equals(this.ddoc._id)) {
throw new DocumentNotFoundError(drid); throw new DocumentNotFoundError(domainId, drid);
} }
} }
} }
+1 -1
View File
@@ -510,7 +510,7 @@ export class ProblemSolutionHandler extends ProblemDetailHandler {
@param('content', Types.Content) @param('content', Types.Content)
async postEditReply(domainId: string, psid: ObjectID, psrid: ObjectID, content: string) { async postEditReply(domainId: string, psid: ObjectID, psrid: ObjectID, content: string) {
const [psdoc, psrdoc] = await solution.getReply(domainId, psid, psrid); const [psdoc, psrdoc] = await solution.getReply(domainId, psid, psrid);
if ((!psdoc) || psdoc.pid !== this.pdoc.docId) throw new SolutionNotFoundError(psid); if ((!psdoc) || psdoc.pid !== this.pdoc.docId) throw new SolutionNotFoundError(domainId, psid);
if (!(psrdoc.owner === this.user._id if (!(psrdoc.owner === this.user._id
&& this.user.hasPerm(PERM.PERM_EDIT_PROBLEM_SOLUTION_REPLY_SELF))) { && this.user.hasPerm(PERM.PERM_EDIT_PROBLEM_SOLUTION_REPLY_SELF))) {
throw new PermissionError(PERM.PERM_EDIT_PROBLEM_SOLUTION_REPLY_SELF); throw new PermissionError(PERM.PERM_EDIT_PROBLEM_SOLUTION_REPLY_SELF);
+1 -1
View File
@@ -380,7 +380,7 @@ export async function edit(
if (!this.RULES[$set.rule]) throw new ValidationError('rule'); if (!this.RULES[$set.rule]) throw new ValidationError('rule');
} }
const tdoc = await document.get(domainId, type, tid); const tdoc = await document.get(domainId, type, tid);
if (!tdoc) throw new ContestNotFoundError(tid); if (!tdoc) throw new ContestNotFoundError(domainId, tid);
this.RULES[$set.rule || tdoc.rule].check(Object.assign(tdoc, $set)); this.RULES[$set.rule || tdoc.rule].check(Object.assign(tdoc, $set));
return await document.set(domainId, type, tid, $set); return await document.set(domainId, type, tid, $set);
} }
+1 -1
View File
@@ -153,7 +153,7 @@ export async function editReply(
export async function delReply(domainId: string, drid: ObjectID) { export async function delReply(domainId: string, drid: ObjectID) {
const drdoc = await getReply(domainId, drid); const drdoc = await getReply(domainId, drid);
if (!drdoc) throw new DocumentNotFoundError(drid); if (!drdoc) throw new DocumentNotFoundError(domainId, drid);
return await Promise.all([ return await Promise.all([
document.deleteOne(domainId, document.TYPE_DISCUSSION_REPLY, drid), document.deleteOne(domainId, document.TYPE_DISCUSSION_REPLY, drid),
document.inc(domainId, document.TYPE_DISCUSSION, drdoc.parentId, 'nReply', -1), document.inc(domainId, document.TYPE_DISCUSSION, drdoc.parentId, 'nReply', -1),
+1 -1
View File
@@ -13,7 +13,7 @@ class SolutionModel {
static async get(domainId: string, psid: ObjectID) { static async get(domainId: string, psid: ObjectID) {
const psdoc = await document.get(domainId, document.TYPE_PROBLEM_SOLUTION, psid); const psdoc = await document.get(domainId, document.TYPE_PROBLEM_SOLUTION, psid);
if (!psdoc) throw new SolutionNotFoundError(); if (!psdoc) throw new SolutionNotFoundError(domainId, psid);
return psdoc; return psdoc;
} }
+1 -1
View File
@@ -93,7 +93,7 @@ export async function count(domainId: string, query: FilterQuery<TrainingDoc>) {
export async function get(domainId: string, tid: ObjectID) { export async function get(domainId: string, tid: ObjectID) {
const tdoc = await document.get(domainId, document.TYPE_TRAINING, tid); const tdoc = await document.get(domainId, document.TYPE_TRAINING, tid);
if (!tdoc) throw new TrainingNotFoundError(tid); if (!tdoc) throw new TrainingNotFoundError(domainId, tid);
for (const i in tdoc.dag) { for (const i in tdoc.dag) {
for (const j in tdoc.dag[i].pids) { for (const j in tdoc.dag[i].pids) {
if (Number.isSafeInteger(parseInt(tdoc.dag[i].pids[j], 10))) { if (Number.isSafeInteger(parseInt(tdoc.dag[i].pids[j], 10))) {