|
|
@ -1,8 +1,11 @@
|
|
|
|
|
|
|
|
import { Logger } from 'hydrooj/src/logger';
|
|
|
|
import DomainModel from 'hydrooj/src/model/domain';
|
|
|
|
import DomainModel from 'hydrooj/src/model/domain';
|
|
|
|
import * as system from 'hydrooj/src/model/system';
|
|
|
|
import * as system from 'hydrooj/src/model/system';
|
|
|
|
import * as bus from 'hydrooj/src/service/bus';
|
|
|
|
import * as bus from 'hydrooj/src/service/bus';
|
|
|
|
import sonic from './service';
|
|
|
|
import sonic from './service';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const logger = new Logger('sonic');
|
|
|
|
|
|
|
|
|
|
|
|
bus.on('problem/add', async (doc, docId) => {
|
|
|
|
bus.on('problem/add', async (doc, docId) => {
|
|
|
|
const union = await DomainModel.searchUnion({ union: doc.domainId, problem: true });
|
|
|
|
const union = await DomainModel.searchUnion({ union: doc.domainId, problem: true });
|
|
|
|
const tasks = [];
|
|
|
|
const tasks = [];
|
|
|
@ -12,7 +15,7 @@ bus.on('problem/add', async (doc, docId) => {
|
|
|
|
sonic.push('problem', `${domainId}@content`, `${doc.domainId}/${docId}`, doc.content.toString()),
|
|
|
|
sonic.push('problem', `${domainId}@content`, `${doc.domainId}/${docId}`, doc.content.toString()),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await Promise.all(tasks);
|
|
|
|
Promise.all(tasks).catch((e) => logger.error(e));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
bus.on('problem/edit', async (pdoc) => {
|
|
|
|
bus.on('problem/edit', async (pdoc) => {
|
|
|
@ -27,7 +30,7 @@ bus.on('problem/edit', async (pdoc) => {
|
|
|
|
.then(() => sonic.push('problem', `${domainId}@content`, id, pdoc.content.toString())),
|
|
|
|
.then(() => sonic.push('problem', `${domainId}@content`, id, pdoc.content.toString())),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await Promise.all(tasks);
|
|
|
|
Promise.all(tasks).catch((e) => logger.error(e));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
bus.on('problem/del', async (domainId, docId) => {
|
|
|
|
bus.on('problem/del', async (domainId, docId) => {
|
|
|
|