core: discussion: add validation to vnode

This commit is contained in:
undefined committed 2023-12-03 13:20:18 +08:00
1 parent a6b9d154ca
commit d8df7f7a40
1 file changed
+1
+1
View File
@@ -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)) {
const model = type === document.TYPE_TRAINING ? training : contest;
if (!ObjectId.isValid(id)) throw new DiscussionNodeNotFoundError(id);
const _id = new ObjectId(id);
const tdoc = await model.get(domainId, _id);
if (!tdoc) throw new DiscussionNodeNotFoundError(id);