2019-03-15 04:48:17 +00:00
|
|
|
import $ from 'cafy';
|
|
|
|
import define from '../../../define';
|
2019-11-06 20:41:44 +00:00
|
|
|
import { deliverQueue, inboxQueue, dbQueue, objectStorageQueue } from '../../../../../queue';
|
2019-03-15 04:48:17 +00:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
tags: ['admin'],
|
|
|
|
|
|
|
|
requireCredential: true,
|
|
|
|
requireModerator: true,
|
|
|
|
|
|
|
|
params: {
|
|
|
|
domain: {
|
2019-11-06 20:41:44 +00:00
|
|
|
validator: $.str.or(['deliver', 'inbox', 'db', 'objectStorage']),
|
2019-03-15 04:48:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
state: {
|
2019-11-06 20:41:44 +00:00
|
|
|
validator: $.str.or(['active', 'waiting', 'delayed']),
|
2019-03-15 04:48:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
limit: {
|
|
|
|
validator: $.optional.num,
|
|
|
|
default: 50
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default define(meta, async (ps) => {
|
|
|
|
const queue =
|
|
|
|
ps.domain === 'deliver' ? deliverQueue :
|
|
|
|
ps.domain === 'inbox' ? inboxQueue :
|
2019-11-06 20:41:44 +00:00
|
|
|
ps.domain === 'db' ? dbQueue :
|
|
|
|
ps.domain === 'objectStorage' ? objectStorageQueue :
|
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
|
|
|
|
2019-11-06 20:41:44 +00:00
|
|
|
return jobs.map(job => {
|
|
|
|
const data = job.data;
|
|
|
|
delete data.content;
|
|
|
|
delete data.user;
|
|
|
|
return {
|
|
|
|
id: job.id,
|
|
|
|
data,
|
|
|
|
attempts: job.attemptsMade,
|
|
|
|
maxAttempts: job.opts ? job.opts.attempts : 0,
|
|
|
|
timestamp: job.timestamp,
|
|
|
|
};
|
|
|
|
});
|
2019-03-15 04:48:17 +00:00
|
|
|
});
|