Integrate project classroom with teacher and friend consultations
This commit is contained in:
@@ -23,10 +23,14 @@ export async function handleCodingTeacherRoutes(
|
||||
const preview = url.pathname.match(
|
||||
/^\/api\/coding\/teacher-preview\/topics(?:\/([^/]+))?(?:\/(messages|events|save|requests\/([^/]+)\/cancel))?$/
|
||||
);
|
||||
const config = url.pathname === '/api/coding/teacher/config';
|
||||
const projectTopics = url.pathname.match(
|
||||
/^\/api\/coding\/projects\/([^/]+)\/(teacher|friend)-topics(?:\/([^/]+))?(?:\/(messages|events|save|requests\/([^/]+)\/cancel))?$/
|
||||
);
|
||||
const role = projectTopics?.[2] === 'friend' || url.pathname === '/api/coding/friend/config' ? 'friend' : 'teacher';
|
||||
const config = url.pathname === '/api/coding/teacher/config' || url.pathname === '/api/coding/friend/config';
|
||||
const draft = url.pathname === '/api/coding/teacher-preview';
|
||||
const pending = url.pathname === '/api/coding/teacher-preview/pending-link';
|
||||
if (!source && !preview && !config && !draft && !pending) return false;
|
||||
if (!source && !preview && !projectTopics && !config && !draft && !pending) return false;
|
||||
if ((config || draft || pending) && req.method !== 'GET') {
|
||||
sendJson(res, 405, { error: '不支持此操作。' });
|
||||
return true;
|
||||
@@ -42,7 +46,7 @@ export async function handleCodingTeacherRoutes(
|
||||
}
|
||||
try {
|
||||
if (config && req.method === 'GET') {
|
||||
sendJson(res, 200, await service.definition());
|
||||
sendJson(res, 200, await service.definition(role));
|
||||
return true;
|
||||
}
|
||||
if (draft && req.method === 'GET') {
|
||||
@@ -54,10 +58,12 @@ export async function handleCodingTeacherRoutes(
|
||||
}
|
||||
const scope: TeacherScope = source
|
||||
? { projectId: decodeURIComponent(source[1]), sourceId: decodeURIComponent(source[2]) }
|
||||
: { projectId: 'preview', sourceId: 'preview' };
|
||||
const id = source?.[3] ?? preview?.[1],
|
||||
action = source?.[4] ?? preview?.[2],
|
||||
requestId = source?.[5] ?? preview?.[3];
|
||||
: projectTopics
|
||||
? { projectId: decodeURIComponent(projectTopics[1]), sourceId: 'project', role }
|
||||
: { projectId: 'preview', sourceId: 'preview' };
|
||||
const id = source?.[3] ?? projectTopics?.[3] ?? preview?.[1],
|
||||
action = source?.[4] ?? projectTopics?.[4] ?? preview?.[2],
|
||||
requestId = source?.[5] ?? projectTopics?.[5] ?? preview?.[3];
|
||||
if (!id && req.method === 'GET') {
|
||||
sendJson(res, 200, await service.list(scope));
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user