站内消息即时通知,测试断线重连

This commit is contained in:
undefined committed 2020-07-14 11:11:20 +08:00
1 parent a93da2badb
commit 900e19382b
14 files changed
+120 -46

No files matched your search

+7 -7
View File
@@ -31,7 +31,7 @@ import {
const { geoip, useragent } = global.Hydro.lib;
class HomeHandler extends Handler {
async homework(domainId) {
async homework(domainId: string) {
if (this.user.hasPerm(PERM.PERM_VIEW_HOMEWORK)) {
const tdocs = await contest.getMulti(domainId, {}, document.TYPE_HOMEWORK)
.sort('beginAt', -1)
@@ -46,11 +46,11 @@ class HomeHandler extends Handler {
return [[], {}];
}
async contest(domainId) {
async contest(domainId: string) {
if (this.user.hasPerm(PERM.PERM_VIEW_CONTEST)) {
const tdocs = await contest.getMulti(domainId)
.sort('beginAt', -1)
.limit(await system.get('CONTESTS_ON_MAIN'))
.limit(await system.get('CONTEST_ON_MAIN'))
.toArray();
const tsdict = await contest.getListStatus(
domainId, this.user._id, tdocs.map((tdoc) => tdoc.docId),
@@ -60,11 +60,11 @@ class HomeHandler extends Handler {
return [[], {}];
}
async training(domainId) {
async training(domainId: string) {
if (this.user.hasPerm(PERM.PERM_VIEW_TRAINING)) {
const tdocs = await training.getMulti(domainId)
.sort('_id', 1)
.limit(await system.get('TRAININGS_ON_MAIN'))
.limit(await system.get('TRAINING_ON_MAIN'))
.toArray();
const tsdict = await training.getListStatus(
domainId, this.user._id, tdocs.map((tdoc) => tdoc.docId),
@@ -74,10 +74,10 @@ class HomeHandler extends Handler {
return [[], {}];
}
async discussion(domainId): Promise<[any[], any]> {
async discussion(domainId: string): Promise<[any[], any]> {
if (this.user.hasPerm(PERM.PERM_VIEW_DISCUSSION)) {
const ddocs = await discussion.getMulti(domainId)
.limit(await system.get('DISCUSSIONS_ON_MAIN'))
.limit(await system.get('DISCUSSION_ON_MAIN'))
.toArray();
const vndict = await discussion.getListVnodes(domainId, ddocs, this);
return [ddocs, vndict];
+4 -2
View File
@@ -34,9 +34,11 @@ class ProblemImportHandler extends Handler {
throw new ValidationError('remoteType');
}
const [pdoc, testdata] = await global.Hydro.lib[`import.${remoteType}`](url, this);
if (pid) pdoc.pid = pid;
if (hidden) pdoc.hidden = true;
const docId = await problem.add(domainId, pdoc.title, pdoc.content, this.user._id, pdoc);
const docId = await problem.add(
domainId, pid || pdoc.pid, pdoc.title, pdoc.content, this.user._id,
pdoc.tag || [], pdoc.category || [], null, pdoc.hidden,
);
if (testdata) {
const file = path.resolve(os.tmpdir(), 'hydro', `import_${domainId}_${pid || pdoc.pid || docId}.zip`);
const w = fs.createWriteStream(file);
+2 -4
View File
@@ -534,13 +534,11 @@ class ProblemCreateHandler extends Handler {
}
@param('title', Types.String, isTitle)
@param('pid', Types.String, isPid)
@param('pid', Types.String, isPid, true)
@param('content', Types.String, isContent)
@param('hidden', Types.Boolean)
async post(domainId: string, title: string, pid: string, content: string, hidden = false) {
pid = await problem.add(domainId, title, content, this.user._id, {
pid, hidden,
});
pid = await problem.add(domainId, pid, title, content, this.user._id, [], [], null, hidden);
this.response.body = { pid };
this.response.redirect = this.url('problem_settings', { pid });
}