core: typo fix

pull/187/head
undefined 3 years ago
parent c3190551dd
commit 77c4f6dd27

@ -113,9 +113,9 @@ export class ContestBoardcastHandler extends Handler {
['Hydro', 'homepage'],
['contest_main', 'contest_main'],
[tdoc.title, 'contest_detail', { tid }, true],
['contest_boardcast'],
['contest_broadcast'],
];
this.response.template = 'contest_boardcast.html';
this.response.template = 'contest_broadcast.html';
this.response.body = path;
}
@ -372,7 +372,7 @@ export class ContestDetailProblemSubmitHandler extends ContestProblemHandler {
contest.updateStatus(domainId, tid, this.user._id, rid, pid),
]);
}
bus.boardcast('record/change', rdoc);
bus.broadcast('record/change', rdoc);
if (!pretest && !contest.canShowSelfRecord.call(this, this.tdoc)) {
this.response.body = { tid };
this.response.redirect = this.url('contest_detail', { tid });
@ -415,7 +415,7 @@ export async function apply() {
Route('contest_create', '/contest/create', ContestEditHandler);
Route('contest_main', '/contest', ContestListHandler, PERM.PERM_VIEW_CONTEST);
Route('contest_detail', '/contest/:tid', ContestDetailHandler, PERM.PERM_VIEW_CONTEST);
Route('contest_boardcast', '/contest/:tid/boardcast', ContestBoardcastHandler);
Route('contest_broadcast', '/contest/:tid/broadcast', ContestBoardcastHandler);
Route('contest_edit', '/contest/:tid/edit', ContestEditHandler, PERM.PERM_VIEW_CONTEST);
Route('contest_scoreboard', '/contest/:tid/scoreboard', ContestScoreboardHandler, PERM.PERM_VIEW_CONTEST);
Route('contest_scoreboard_download', '/contest/:tid/export/:ext', ContestScoreboardDownloadHandler, PERM.PERM_VIEW_CONTEST);

@ -240,7 +240,7 @@ class HomeworkDetailProblemSubmitHandler extends HomeworkDetailProblemHandler {
rid, pid, false, 0, document.TYPE_HOMEWORK),
]);
}
bus.boardcast('record/change', rdoc);
bus.broadcast('record/change', rdoc);
this.response.body.tid = tid;
this.response.body.rid = rid;
if (pretest || contest.canShowSelfRecord.call(this, this.tdoc)) this.response.redirect = this.url('record_detail', { rid });

@ -72,7 +72,7 @@ export async function next(body: JudgeResultBody) {
if (body.memory !== undefined) $set.memory = body.memory;
if (body.progress !== undefined) $set.progress = body.progress;
rdoc = await record.update(rdoc.domainId, body.rid, $set, $push);
bus.boardcast('record/change', rdoc, $set, $push);
bus.broadcast('record/change', rdoc, $set, $push);
}
export async function end(body: JudgeResultBody) {
@ -98,7 +98,7 @@ export async function end(body: JudgeResultBody) {
await sleep(100); // Make sure that all 'next' event already triggered
rdoc = await record.update(rdoc.domainId, body.rid, $set, $push, $unset);
await postJudge(rdoc);
bus.boardcast('record/change', rdoc); // trigger a full update
bus.broadcast('record/change', rdoc); // trigger a full update
}
export class JudgeFilesDownloadHandler extends Handler {
@ -153,7 +153,7 @@ class JudgeConnectionHandler extends ConnectionHandler {
this.processing = t;
const $set = { status: builtin.STATUS.STATUS_FETCHED };
const rdoc = await record.update(t.domainId, t.rid, $set, {});
bus.boardcast('record/change', rdoc, $set, {});
bus.broadcast('record/change', rdoc, $set, {});
}
async message(msg) {

@ -267,7 +267,7 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
]);
}
bus.boardcast('record/change', rdoc);
bus.broadcast('record/change', rdoc);
this.response.body = { rid };
this.response.redirect = this.url('record_detail', { rid });
}
@ -284,7 +284,7 @@ export class ProblemPretestHandler extends ProblemDetailHandler {
lang, code, true, input,
);
const rdoc = await record.get(domainId, rid);
bus.boardcast('record/change', rdoc);
bus.broadcast('record/change', rdoc);
this.response.body = { rid };
}
}

@ -22,7 +22,7 @@ class MessageModel {
const mdoc = {
from, to, content, _id: res.insertedId, flag,
};
if (from !== to) bus.boardcast('user/message', to, mdoc);
if (from !== to) bus.broadcast('user/message', to, mdoc);
await user.inc(to, 'unreadMsg', 1);
return mdoc;
}

@ -36,10 +36,10 @@ export function getMany(keys: string[]): any[] {
return keys.map((key) => cache[key]);
}
export async function set<K extends keyof SystemKeys>(_id: K, value: SystemKeys[K], boardcast?: boolean): Promise<SystemKeys[K]>;
export async function set<K>(_id: string, value: K, boardcast?: boolean): Promise<K>;
export async function set(_id: string, value: any, boardcast = true) {
if (boardcast) bus.boardcast('system/setting', { [_id]: value });
export async function set<K extends keyof SystemKeys>(_id: K, value: SystemKeys[K], broadcast?: boolean): Promise<SystemKeys[K]>;
export async function set<K>(_id: string, value: K, broadcast?: boolean): Promise<K>;
export async function set(_id: string, value: any, broadcast = true) {
if (broadcast) bus.broadcast('system/setting', { [_id]: value });
const res = await coll.findOneAndUpdate(
{ _id },
{ $set: { value } },

@ -184,7 +184,7 @@ export async function bail<K extends keyof EventMap>(name: K, ...args: Parameter
return null;
}
export function boardcast<K extends keyof EventMap>(event: K, ...payload: Parameters<EventMap[K]>) {
export function broadcast<K extends keyof EventMap>(event: K, ...payload: Parameters<EventMap[K]>) {
// Process forked by pm2 would also have process.send
if (process.send && !cluster.isMaster) {
process.send({
@ -217,5 +217,5 @@ process.on('message', messageHandler);
cluster.on('message', messageHandler);
global.Hydro.service.bus = {
addListener, bail, boardcast, emit, on, off, once, parallel, prependListener, removeListener, serial,
addListener, bail, broadcast, emit, on, off, once, parallel, prependListener, removeListener, serial,
};

Loading…
Cancel
Save