2019-03-15 04:48:17 +00:00
|
|
|
import $ from 'cafy';
|
|
|
|
import define from '../../../define';
|
|
|
|
import { deliverQueue, inboxQueue } from '../../../../../queue';
|
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
tags: ['admin'],
|
|
|
|
|
|
|
|
requireCredential: true,
|
|
|
|
requireModerator: true,
|
|
|
|
|
|
|
|
params: {
|
|
|
|
domain: {
|
|
|
|
validator: $.str,
|
|
|
|
},
|
|
|
|
|
|
|
|
state: {
|
|
|
|
validator: $.str,
|
|
|
|
},
|
|
|
|
|
|
|
|
limit: {
|
|
|
|
validator: $.optional.num,
|
|
|
|
default: 50
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default define(meta, async (ps) => {
|
|
|
|
const queue =
|
|
|
|
ps.domain === 'deliver' ? deliverQueue :
|
|
|
|
ps.domain === 'inbox' ? inboxQueue :
|
2019-04-12 16:43:22 +00:00
|
|
|
null as never;
|
2019-03-15 04:48:17 +00:00
|
|
|
|
2019-04-12 16:43:22 +00:00
|
|
|
const jobs = await queue.getJobs([ps.state], 0, ps.limit!);
|
2019-03-15 04:48:17 +00:00
|
|
|
|
|
|
|
return jobs.map(job => ({
|
|
|
|
id: job.id,
|
|
|
|
data: job.data,
|
|
|
|
attempts: job.attemptsMade,
|
|
|
|
}));
|
|
|
|
});
|