core: fix system_setting to update codeLang list

This commit is contained in:
undefined committed 2021-03-11 13:21:55 +08:00
1 parent e7780c56bb
commit be0b90dcd4
8 files changed
+23 -10

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js",
"version": "2.4.10",
"version": "2.4.11",
"os": [
"linux"
],
-1
View File
@@ -226,7 +226,6 @@ async function postInit() {
this.config,
{ next: this.next },
);
console.log(this.config);
this.stat.judge = new Date();
await judge[this.config.type || 'default'].judge(this);
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.20.17",
"version": "2.20.18",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
-1
View File
@@ -155,7 +155,6 @@ class DomainPermissionHandler extends ManageHandler {
const roles = {};
delete this.request.body.csrfToken;
for (const role in this.request.body) {
console.log(role, this.request.body[role]);
const perms = this.request.body[role] instanceof Array
? this.request.body[role]
: [this.request.body[role]];
+2 -1
View File
@@ -2,7 +2,8 @@
import { Udoc } from '../interface';
/* Why nocheck?
/*
* Why nocheck?
* BitInt requires at least ES2020, but we can't use it as
* NodeJS doesn't support some of this new features.
* e.g.: object?.property
+1 -1
View File
@@ -201,7 +201,7 @@ bus.once('app/started', async () => {
bus.on('system/setting', (args) => {
if (!args.lang?.texts) return;
SETTINGS_BY_KEY['lang.texts'].value = args.lang.texts;
SETTINGS_BY_KEY['codeLang'].range = args.lang.texts;
});
global.Hydro.model.setting = {
+4 -3
View File
@@ -15,7 +15,7 @@ import sockjs from 'sockjs';
import type { SetOption } from 'cookies';
import serialize, { SerializeJSOptions } from 'serialize-javascript';
import { argv } from 'yargs';
import { lrucache } from '../utils';
import { errorMessage, lrucache } from '../utils';
import { User, DomainDoc } from '../interface';
import { Logger } from '../logger';
import {
@@ -478,7 +478,8 @@ export class Handler extends HandlerCommon {
if (!this.response.body) return;
try {
await this.renderBody();
} catch (error) {
} catch (err) {
const error = errorMessage(err);
this.response.status = error instanceof UserFacingError ? error.code : 500;
if (this.request.json) this.response.body = { error };
else {
@@ -576,7 +577,7 @@ export class Handler extends HandlerCommon {
this.response.status = error instanceof UserFacingError ? error.code : 500;
this.response.template = error instanceof UserFacingError ? 'error.html' : 'bsod.html';
this.response.body = {
error: { message: error.msg(), params: error.params, stack: error.stack },
error: { message: error.msg(), params: error.params, stack: errorMessage(error.stack) },
};
await this.finish().catch(() => { });
}
+14 -1
View File
@@ -1,7 +1,7 @@
import fs from 'fs';
import { Duplex } from 'stream';
import cluster from 'cluster';
import path from 'path';
import path, { sep } from 'path';
import serialize from 'serialize-javascript';
import Lru from 'lru-cache';
import { ObjectID } from 'mongodb';
@@ -266,3 +266,16 @@ export const log2 = (val: bigint | number) => {
for (let i = 0; ; i++) if (!(val >> i)) return i - 1;
}
};
export function errorMessage(err: Error | string) {
const t = typeof err === 'string' ? err : err.stack;
const q = t.split('\n');
for (let i = 0; i < q.length; i++) {
if (!q[i].startsWith(' at')) continue;
if (q[i].includes(`${sep}@hydrooj${sep}`)) q[i] = q[i].split(`@hydrooj${sep}`)[1];
else if (q[i].includes(`${sep}hydrooj${sep}`)) q[i] = `hydrooj${sep}${q[i].split(`hydrooj/${sep}`)[1]}`;
}
if (typeof err === 'string') return q.join('\n');
err.stack = q.join('\n');
return err;
}