mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
fix ci issues
This commit is contained in:
26 files changed
+108
-85
No files matched your search
@@ -254,9 +254,9 @@ class HomeSecurityHandler extends Handler {
|
||||
|
||||
@param('platform', Types.String)
|
||||
async postLinkAccount({ }, platform: string) {
|
||||
if (!global.Hydro.module.oauth[platform]) throw new ValidationError('platform');
|
||||
if (!this.ctx.oauth.providers[platform]) throw new ValidationError('platform');
|
||||
this.session.oauthBind = platform;
|
||||
await global.Hydro.module.oauth[platform].get.call(this);
|
||||
await this.ctx.oauth.providers[platform].get.call(this);
|
||||
}
|
||||
|
||||
@param('tokenDigest', Types.String)
|
||||
|
||||
@@ -115,7 +115,7 @@ export class JudgeResultCallbackContext {
|
||||
return this.operationPromise;
|
||||
}
|
||||
|
||||
static async postJudge(rdoc: RecordDoc) {
|
||||
static async postJudge(rdoc: RecordDoc, context?: JudgeResultCallbackContext) {
|
||||
if (rdoc.contest?.toString().startsWith('0'.repeat(23))) return;
|
||||
const accept = rdoc.status === builtin.STATUS.STATUS_ACCEPTED;
|
||||
const updated = await problem.updateStatus(rdoc.domainId, rdoc.pid, rdoc.uid, rdoc._id, rdoc.status, rdoc.score);
|
||||
@@ -134,7 +134,7 @@ export class JudgeResultCallbackContext {
|
||||
problem.inc(pdoc.domainId, pdoc.docId, `stats.s${Math.floor(rdoc.score)}`, 1),
|
||||
]);
|
||||
}
|
||||
await app.parallel('record/judge', rdoc, updated, pdoc, this);
|
||||
await app.parallel('record/judge', rdoc, updated, pdoc, context);
|
||||
}
|
||||
|
||||
async _end(body: Partial<JudgeResultBody>) {
|
||||
@@ -155,7 +155,7 @@ export class JudgeResultCallbackContext {
|
||||
|
||||
const rdoc = await record.update(this.task.domainId, new ObjectId(this.task.rid as string), $set, $push, $unset);
|
||||
if (rdoc) bus.broadcast('record/change', rdoc, null, null, body); // trigger a full update
|
||||
await JudgeResultCallbackContext.postJudge(rdoc);
|
||||
await JudgeResultCallbackContext.postJudge(rdoc, this);
|
||||
this.resolve(rdoc);
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ export async function apply(ctx: Context) {
|
||||
const priority = await record.submissionPriority(rdoc.uid, -5000 - rdocs.length * 5 - 50);
|
||||
await record.judge(rdoc.domainId, rdocs.map((r) => r._id), priority, {}, { hackRejudge: input });
|
||||
} catch (e) {
|
||||
t.next({
|
||||
t?.next?.({
|
||||
rid: rdoc._id.toString(),
|
||||
domainId: rdoc.domainId,
|
||||
key: 'next',
|
||||
|
||||
@@ -4,7 +4,8 @@ import moment from 'moment-timezone';
|
||||
import type { Binary } from 'mongodb';
|
||||
import type { Context } from '../context';
|
||||
import {
|
||||
AuthOperationError, BadRequestError, BlacklistedError, BuiltinLoginError, ForbiddenError, InvalidTokenError,
|
||||
AuthOperationError, BadRequestError, BlacklistedError, BuiltinLoginError,
|
||||
ForbiddenError, InvalidTokenError, NotFoundError,
|
||||
SystemError, UserAlreadyExistError, UserFacingError,
|
||||
UserNotFoundError, ValidationError, VerifyPasswordError,
|
||||
} from '../error';
|
||||
@@ -279,9 +280,9 @@ class UserRegisterWithCodeHandler extends Handler {
|
||||
domainId: string, password: string, verify: string,
|
||||
uname = '', code: string,
|
||||
) {
|
||||
if (global.Hydro.module.oauth[this.tdoc.identity.provider].lockUsername) {
|
||||
uname = this.tdoc.identity.username;
|
||||
}
|
||||
const provider = this.ctx.oauth.providers[this.tdoc.identity.provider];
|
||||
if (!provider) throw new SystemError(`OAuth provider ${this.tdoc.identity.provider} not found`);
|
||||
if (provider.lockUsername) uname = this.tdoc.identity.username;
|
||||
if (!Types.Username[1](uname)) throw new ValidationError('uname');
|
||||
if (password !== verify) throw new VerifyPasswordError();
|
||||
const randomEmail = `${String.random(12)}@invalid.local`; // some random email to remove in the future
|
||||
@@ -428,7 +429,7 @@ class OauthHandler extends Handler {
|
||||
|
||||
@param('type', Types.Key)
|
||||
async get(domainId: string, type: string) {
|
||||
await global.Hydro.module.oauth[type]?.get.call(this);
|
||||
await this.ctx.oauth.providers[type]?.get.call(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,8 +437,8 @@ class OauthCallbackHandler extends Handler {
|
||||
noCheckPermView = true;
|
||||
|
||||
async get(args: any) {
|
||||
if (!global.Hydro.module.oauth[args.type]) throw new UserFacingError('Oauth type');
|
||||
const r = await global.Hydro.module.oauth[args.type].callback.call(this, args);
|
||||
if (!this.ctx.oauth.providers[args.type]) throw new UserFacingError('Oauth type');
|
||||
const r = await this.ctx.oauth.providers[args.type].callback.call(this, args);
|
||||
if (this.session.oauthBind === args.type) {
|
||||
delete this.session.oauthBind;
|
||||
const existing = await this.ctx.oauth.get(args.type, r._id);
|
||||
@@ -529,6 +530,17 @@ export async function apply(ctx: Context) {
|
||||
if (system.get('server.contestmode')) {
|
||||
ctx.Route('contest_mode', '/contestmode', ContestModeHandler, PRIV.PRIV_EDIT_SYSTEM);
|
||||
}
|
||||
ctx.oauth.provide('mail', {
|
||||
text: 'Mail',
|
||||
name: 'mail',
|
||||
hidden: true,
|
||||
async get() {
|
||||
throw new NotFoundError();
|
||||
},
|
||||
async callback() {
|
||||
throw new NotFoundError();
|
||||
},
|
||||
});
|
||||
ctx.inject(['api'], ({ api }) => {
|
||||
api.value('User', [
|
||||
['_id', 'Int!'],
|
||||
|
||||
Reference in new issue
Block a user