mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: move problem/del to problem/delete
This commit is contained in:
5 files changed
+3
-5
No files matched your search
@@ -107,7 +107,7 @@ export default class ElasticSearchService extends Service {
|
|||||||
document: processDocument(pdoc),
|
document: processDocument(pdoc),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.ctx.on('problem/del', async (domainId, docId) => {
|
this.ctx.on('problem/delete', async (domainId, docId) => {
|
||||||
await this.client.delete({
|
await this.client.delete({
|
||||||
index: 'problem',
|
index: 'problem',
|
||||||
id: `${domainId}/${docId}`,
|
id: `${domainId}/${docId}`,
|
||||||
|
|||||||
@@ -636,7 +636,7 @@ export class ContestFileDownloadHandler extends ContestDetailBaseHandler {
|
|||||||
@param('noDisposition', Types.Boolean)
|
@param('noDisposition', Types.Boolean)
|
||||||
@param('type', Types.Range(['public', 'private']), true)
|
@param('type', Types.Range(['public', 'private']), true)
|
||||||
async get(domainId: string, tid: ObjectId, filename: string, noDisposition = false, type = 'private') {
|
async get(domainId: string, tid: ObjectId, filename: string, noDisposition = false, type = 'private') {
|
||||||
if (type === 'private' && !this.user.own(this.tdoc)) {
|
if (type === 'private' && !this.user.own(this.tdoc) && !this.user.hasPerm(PERM.PERM_EDIT_CONTEST)) {
|
||||||
if (!this.tsdoc?.attend) throw new ContestNotAttendedError(domainId, tid);
|
if (!this.tsdoc?.attend) throw new ContestNotAttendedError(domainId, tid);
|
||||||
if (!contest.isOngoing(this.tdoc) && !contest.isDone(this.tdoc)) throw new ContestNotLiveError(domainId, tid);
|
if (!contest.isOngoing(this.tdoc) && !contest.isDone(this.tdoc)) throw new ContestNotLiveError(domainId, tid);
|
||||||
if (!this.tsdoc.startAt) await contest.setStatus(domainId, tid, this.user._id, { startAt: new Date() });
|
if (!this.tsdoc.startAt) await contest.setStatus(domainId, tid, this.user._id, { startAt: new Date() });
|
||||||
|
|||||||
@@ -282,7 +282,6 @@ export class ProblemModel {
|
|||||||
.then((items) => storage.del(items.map((item) => `problem/${domainId}/${docId}/${item.name}`))),
|
.then((items) => storage.del(items.map((item) => `problem/${domainId}/${docId}/${item.name}`))),
|
||||||
bus.parallel('problem/delete', domainId, docId),
|
bus.parallel('problem/delete', domainId, docId),
|
||||||
]);
|
]);
|
||||||
await bus.emit('problem/del', domainId, docId);
|
|
||||||
return !!res[0][0].deletedCount;
|
return !!res[0][0].deletedCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ export interface EventMap {
|
|||||||
'problem/before-edit': (doc: Partial<ProblemDoc>, $unset: OnlyFieldsOfType<ProblemDoc, any, true | '' | 1>) => VoidReturn;
|
'problem/before-edit': (doc: Partial<ProblemDoc>, $unset: OnlyFieldsOfType<ProblemDoc, any, true | '' | 1>) => VoidReturn;
|
||||||
'problem/edit': (doc: ProblemDoc) => VoidReturn;
|
'problem/edit': (doc: ProblemDoc) => VoidReturn;
|
||||||
'problem/before-del': (domainId: string, docId: number) => VoidReturn;
|
'problem/before-del': (domainId: string, docId: number) => VoidReturn;
|
||||||
'problem/del': (domainId: string, docId: number) => VoidReturn;
|
|
||||||
'problem/list': (query: Filter<ProblemDoc>, handler: any, sort?: string[]) => VoidReturn;
|
'problem/list': (query: Filter<ProblemDoc>, handler: any, sort?: string[]) => VoidReturn;
|
||||||
'problem/get': (doc: ProblemDoc, handler: any) => VoidReturn;
|
'problem/get': (doc: ProblemDoc, handler: any) => VoidReturn;
|
||||||
'problem/delete': (domainId: string, docId: number) => VoidReturn;
|
'problem/delete': (domainId: string, docId: number) => VoidReturn;
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export class SonicService extends Service {
|
|||||||
.then(() => this.push('problem', `${pdoc.domainId}@content`, id, pdoc.content.toString())),
|
.then(() => this.push('problem', `${pdoc.domainId}@content`, id, pdoc.content.toString())),
|
||||||
]).catch((e) => logger.error(e));
|
]).catch((e) => logger.error(e));
|
||||||
});
|
});
|
||||||
yield this.ctx.on('problem/del', async (domainId, docId) => {
|
yield this.ctx.on('problem/delete', async (domainId, docId) => {
|
||||||
const id = `${domainId}/${docId}`;
|
const id = `${domainId}/${docId}`;
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.flusho('problem', `${domainId}@title`, id),
|
this.flusho('problem', `${domainId}@title`, id),
|
||||||
|
|||||||
Reference in new issue
Block a user