mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: +hook:record/judge, +setting displayName for userImport
This commit is contained in:
1 parent
ea3a386b77
commit
4a613c47d5
7 files changed
+34
-11
No files matched your search
@@ -33,6 +33,7 @@ async function _postJudge(rdoc: Rdoc) {
|
||||
: await problem.get(rdoc.domainId, rdoc.pid);
|
||||
const difficulty = difficultyAlgorithm(pdoc.nSubmit, pdoc.nAccept);
|
||||
await problem.edit(pdoc.domainId, pdoc.docId, { difficulty });
|
||||
await bus.serial('record/judge', rdoc, updated);
|
||||
}
|
||||
|
||||
export async function next(body: JudgeResultBody) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import * as system from '../model/system';
|
||||
import user from '../model/user';
|
||||
import { STATUS, PRIV } from '../model/builtin';
|
||||
import record from '../model/record';
|
||||
import domain from '../model/domain';
|
||||
import {
|
||||
Route, Connection, Handler, ConnectionHandler, param, Types,
|
||||
} from '../service/server';
|
||||
@@ -193,14 +194,23 @@ class SystemUserImportHandler extends SystemHandler {
|
||||
const messages = [];
|
||||
for (const i in users) {
|
||||
const u = users[i];
|
||||
const [email, username, password] = u.split(',').map((t) => t.trim());
|
||||
const [email, username, password, displayName] = u.split(',').map((t) => t.trim());
|
||||
if (email && username && password) {
|
||||
if (!isEmail(email)) messages.push(`Line ${i + 1}: Invalid email.`);
|
||||
else if (!isUname(username)) messages.push(`Line ${i + 1}: Invalid username`);
|
||||
else if (!isPassword(password)) messages.push(`Line ${i + 1}: Invalid password`);
|
||||
else {
|
||||
udocs.push({ email, username, password });
|
||||
if (!confirm) tasks.push(user.create(email, username, password));
|
||||
udocs.push({
|
||||
email, username, password, displayName,
|
||||
});
|
||||
if (!confirm) {
|
||||
tasks.push(
|
||||
user.create(email, username, password).then((uid) => {
|
||||
if (displayName) return domain.setUserInDomain(domainId, uid, { displayName });
|
||||
return Promise.resolve();
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
} else messages.push(`Line ${i + 1}: Input invalid.`);
|
||||
}
|
||||
|
||||
@@ -447,6 +447,7 @@ export class ProblemSolutionHandler extends ProblemDetailHandler {
|
||||
this.response.body = {
|
||||
path, psdocs, page, pcount, pscount, udict, pssdict, pdoc: this.pdoc,
|
||||
};
|
||||
await bus.serial('handler/solution/get', this);
|
||||
}
|
||||
|
||||
@param('content', Types.String, isContent)
|
||||
|
||||
Reference in new issue
Block a user