core: discussion not found error msg (#1079)

Co-authored-by: undefined <i@undefined.moe>
This commit is contained in:
035966-L3andundefined authored and GitHub committed 2025-11-09 20:02:19 +00:00
1 parent 9898c56de1
commit 1282f80c1a
2 files changed
+8 -5

No files matched your search

+4 -3
View File
@@ -276,15 +276,16 @@ export function flushNodes(domainId: string) {
export async function getVnode(domainId: string, type: number, id: string, uid?: number) {
if (type === document.TYPE_PROBLEM) {
const pdoc = await problem.get(domainId, Number.isSafeInteger(+id) ? +id : id, problem.PROJECTION_LIST);
if (!pdoc) throw new DiscussionNodeNotFoundError(`problem/${id}`);
if (!pdoc) throw new DiscussionNodeNotFoundError(domainId, `problem/${id}`);
return { ...pdoc, type, id: pdoc.docId };
}
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(`contest/${id}`);
const typeName = type === document.TYPE_TRAINING ? 'training' : 'contest';
if (!ObjectId.isValid(id)) throw new DiscussionNodeNotFoundError(domainId, `${typeName}/${id}`);
const _id = new ObjectId(id);
const tdoc = await model.get(domainId, _id);
if (!tdoc) throw new DiscussionNodeNotFoundError(`contest/${id}`);
if (!tdoc) throw new DiscussionNodeNotFoundError(domainId, `${typeName}/${id}`);
if (uid) {
const tsdoc = await model.getStatus(domainId, _id, uid);
tdoc.attend = tsdoc?.attend || tsdoc?.enroll;