mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: discussion panel
This commit is contained in:
1 parent
18450dafea
commit
675e28abc5
5 files changed
+23
-27
No files matched your search
@@ -232,15 +232,21 @@ export function getNode(domainId: string, _id: string) {
|
||||
return document.get(domainId, document.TYPE_DISCUSSION_NODE, _id);
|
||||
}
|
||||
|
||||
export async function getVnode(domainId: string, type: number, id: 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);
|
||||
if (!pdoc) throw new DiscussionNodeNotFoundError(id);
|
||||
return { ...pdoc, type, id };
|
||||
}
|
||||
if ([document.TYPE_CONTEST, document.TYPE_TRAINING, document.TYPE_HOMEWORK].includes(type as any)) {
|
||||
const tdoc = await (type === document.TYPE_TRAINING ? training : contest).get(domainId, new ObjectID(id), type as any);
|
||||
const model = type === document.TYPE_TRAINING ? training : contest;
|
||||
const _id = new ObjectID(id);
|
||||
const tdoc = await model.get(domainId, _id, type as any);
|
||||
if (!tdoc) throw new DiscussionNodeNotFoundError(id);
|
||||
if (uid) {
|
||||
const tsdoc = await model.getStatus(domainId, _id, uid);
|
||||
tdoc.attend = tsdoc.attend || tsdoc.enroll;
|
||||
}
|
||||
return { ...tdoc, type, id };
|
||||
}
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user