mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: add user import hooks
This commit is contained in:
3 files changed
+10
-5
No files matched your search
@@ -26,7 +26,7 @@ class FpsProblemImportHandler extends Handler {
|
||||
samples: p.sample_input?.map((input, i) => [input, p.sample_output[i]]),
|
||||
hint: p.hint?.[0],
|
||||
source: p.source?.join(' '),
|
||||
}, 'html').replace(/<math xm<x>lns=/g, '<math xmlns=').replace(/\[\/?md]/g, '');
|
||||
}, 'html', (s) => this.translate(s)).replace(/<math xm<x>lns=/g, '<math xmlns=').replace(/\[\/?md]/g, '');
|
||||
const config: ProblemConfigFile = {
|
||||
time: p.time_limit[0]._ + p.time_limit[0].$.unit,
|
||||
memory: p.memory_limit[0]._ + p.memory_limit[0].$.unit,
|
||||
|
||||
@@ -248,12 +248,13 @@ class SystemUserImportHandler extends SystemHandler {
|
||||
groups[data.group] ||= [];
|
||||
groups[data.group].push(email);
|
||||
}
|
||||
if (data.school) payload.school = data.school;
|
||||
if (data.studentId) payload.studentId = data.studentId;
|
||||
Object.assign(payload, data);
|
||||
} catch (e) { }
|
||||
udocs.push({
|
||||
email, username, password, displayName, payload,
|
||||
Object.assign(payload, {
|
||||
email, username, password, displayName,
|
||||
});
|
||||
await this.ctx.serial('user/import/parse', payload);
|
||||
udocs.push(payload);
|
||||
}
|
||||
} else messages.push(`Line ${+i + 1}: Input invalid.`);
|
||||
}
|
||||
@@ -266,6 +267,7 @@ class SystemUserImportHandler extends SystemHandler {
|
||||
if (udoc.displayName) await domain.setUserInDomain(domainId, uid, { displayName: udoc.displayName });
|
||||
if (udoc.payload?.school) await user.setById(uid, { school: udoc.payload.school });
|
||||
if (udoc.payload?.studentId) await user.setById(uid, { studentId: udoc.payload.studentId });
|
||||
await this.ctx.serial('user/import/create', uid, udoc);
|
||||
} catch (e) {
|
||||
messages.push(e.message);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,9 @@ export interface EventMap extends KnownHandlerEvents {
|
||||
'user/get': (udoc: User) => void
|
||||
'user/delcache': (content: string | true) => void
|
||||
|
||||
'user/import/parse': (payload: any) => VoidReturn
|
||||
'user/import/create': (uid: number, udoc: any) => VoidReturn
|
||||
|
||||
'domain/create': (ddoc: DomainDoc) => VoidReturn
|
||||
'domain/before-get': (query: Filter<DomainDoc>) => VoidReturn
|
||||
'domain/get': (ddoc: DomainDoc) => VoidReturn
|
||||
|
||||
Reference in new issue
Block a user