mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: discussion: add validation to vnode
This commit is contained in:
1 file changed
+1
@@ -280,6 +280,7 @@ export async function getVnode(domainId: string, type: number, id: string, uid?:
|
|||||||
}
|
}
|
||||||
if ([document.TYPE_CONTEST, document.TYPE_TRAINING].includes(type as any)) {
|
if ([document.TYPE_CONTEST, document.TYPE_TRAINING].includes(type as any)) {
|
||||||
const model = type === document.TYPE_TRAINING ? training : contest;
|
const model = type === document.TYPE_TRAINING ? training : contest;
|
||||||
|
if (!ObjectId.isValid(id)) throw new DiscussionNodeNotFoundError(id);
|
||||||
const _id = new ObjectId(id);
|
const _id = new ObjectId(id);
|
||||||
const tdoc = await model.get(domainId, _id);
|
const tdoc = await model.get(domainId, _id);
|
||||||
if (!tdoc) throw new DiscussionNodeNotFoundError(id);
|
if (!tdoc) throw new DiscussionNodeNotFoundError(id);
|
||||||
|
|||||||
Reference in new issue
Block a user