diff --git a/package.json b/package.json index 7d1c10c8..cb16183e 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "@shelf/jest-mongodb": "^1.2.3", "@types/cross-spawn": "^6.0.2", "@types/jest": "^26.0.23", - "@types/node": "^14.14.41", + "@types/node": "^15.0.1", "@types/semver": "^7.3.5", "@typescript-eslint/eslint-plugin": "^4.21.0", "@typescript-eslint/parser": "^4.21.0", diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index b8444caa..9b6cc8a9 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.24.0", + "version": "2.24.1", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", @@ -30,7 +30,7 @@ "minio": "7.0.17", "moment-timezone": "^0.5.32", "mongodb": "^3.6.6", - "nodemailer": "^6.5.0", + "nodemailer": "^6.6.0", "p-queue": "^6.6.2", "reflect-metadata": "^0.1.13", "serialize-javascript": "^5.0.1", diff --git a/packages/hydrooj/src/handler/judge.ts b/packages/hydrooj/src/handler/judge.ts index dbe5c452..a7b52f29 100644 --- a/packages/hydrooj/src/handler/judge.ts +++ b/packages/hydrooj/src/handler/judge.ts @@ -143,7 +143,7 @@ class JudgeConnectionHandler extends ConnectionHandler { } async message(msg) { - logger.info('%o', msg); + if (msg.key !== 'ping') logger.info('%o', msg); if (msg.key === 'next') await next(msg); else if (msg.key === 'end') { await end({ judger: this.user._id, ...msg }); diff --git a/packages/hydrooj/src/model/blacklist.ts b/packages/hydrooj/src/model/blacklist.ts index c0e902a8..bc55ba29 100644 --- a/packages/hydrooj/src/model/blacklist.ts +++ b/packages/hydrooj/src/model/blacklist.ts @@ -10,7 +10,7 @@ class BlackListModel { static async add(id: string, expire?: Date | number) { let expireAt; if (expire === 0) expireAt = moment().add(1000, 'months').toDate(); - if (typeof expire === 'number') expireAt = moment().add(expire, 'months').toDate(); + else if (typeof expire === 'number') expireAt = moment().add(expire, 'months').toDate(); else if (expire instanceof Date) expireAt = expire; else expireAt = new Date(new Date().getTime() + 365 * 24 * 60 * 60 * 1000); const res = await coll.findOneAndUpdate( diff --git a/packages/hydrooj/src/model/discussion.ts b/packages/hydrooj/src/model/discussion.ts index 7a8c0adb..3e514d80 100644 --- a/packages/hydrooj/src/model/discussion.ts +++ b/packages/hydrooj/src/model/discussion.ts @@ -4,7 +4,7 @@ import problem from './problem'; import * as contest from './contest'; import * as training from './training'; import * as document from './document'; -import { DocumentNotFoundError } from '../error'; +import { DiscussionNodeNotFoundError, DocumentNotFoundError } from '../error'; import { Drdoc, Drrdoc, Document } from '../interface'; import { buildProjection } from '../utils'; import * as bus from '../service/bus'; @@ -225,37 +225,20 @@ export function getNode(domainId: string, _id: string) { export async function getVnode(domainId: string, type: number, id: string) { if (type === document.TYPE_PROBLEM) { - // @ts-ignore - if (Number.isSafeInteger(parseInt(id, 10))) id = parseInt(id, 10); - const pdoc = await problem.get(domainId, id); - if (!pdoc) return null; + const pdoc = await problem.get(domainId, Number.isSafeInteger(+id) ? +id : id); + if (!pdoc) throw new DiscussionNodeNotFoundError(id); return { ...pdoc, type, id }; } - if (type === document.TYPE_CONTEST) { - const tdoc = await contest.get(domainId, new ObjectID(id)); - return { ...tdoc, type, id }; - } - if (type === document.TYPE_DISCUSSION_NODE) { - const ndoc = await getNode(domainId, id); - return { - ...ndoc, - title: id, - type, - id, - }; - } - if (type === document.TYPE_TRAINING) { - const tdoc = await training.get(domainId, new ObjectID(id)); - return { ...tdoc, type, id }; - } - if (type === document.TYPE_HOMEWORK) { - const tdoc = await contest.get(domainId, new ObjectID(id), document.TYPE_HOMEWORK); + if ([document.TYPE_CONTEST, document.TYPE_TRAINING, document.TYPE_HOMEWORK].includes(type as any)) { + const tdoc = await (type === document.TYPE_TRAINING ? training : contest).get(domainId, new ObjectID(id), type as any); + if (!tdoc) throw new DiscussionNodeNotFoundError(id); return { ...tdoc, type, id }; } return { - title: 'Missing Node', - type: 'Unknown', - id: new ObjectID(), + ...await getNode(domainId, id), + title: id, + type, + id, }; } diff --git a/packages/login-with-qq/package.json b/packages/login-with-qq/package.json index e2d6a721..dabefa13 100644 --- a/packages/login-with-qq/package.json +++ b/packages/login-with-qq/package.json @@ -9,6 +9,6 @@ "ws": "^7.4.5" }, "devDependencies": { - "@types/ws": "^7.4.1" + "@types/ws": "^7.4.2" } } diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index 587f3a86..0cf97510 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -7,7 +7,7 @@ "repository": "https://github.com/hydro-dev/Hydro.git", "devDependencies": { "@babel/cli": "^7.13.14", - "@babel/core": "^7.13.14", + "@babel/core": "^7.14.0", "@babel/eslint-parser": "7.13.14", "@babel/plugin-proposal-class-properties": "^7.13.0", "@babel/plugin-proposal-export-namespace-from": "^7.12.13", @@ -18,10 +18,10 @@ "@babel/plugin-syntax-dynamic-import": "^7.0.0", "@babel/plugin-syntax-import-meta": "^7.10.4", "@babel/plugin-transform-runtime": "^7.13.10", - "@babel/preset-env": "^7.13.10", + "@babel/preset-env": "^7.14.0", "@babel/preset-react": "^7.13.13", "@babel/register": "^7.13.14", - "@babel/runtime-corejs2": "^7.13.10", + "@babel/runtime-corejs2": "^7.14.0", "@hydrooj/utils": "^1.0.7", "ansi_up": "^5.0.1", "autoprefixer": "^9.8.6",