2022-09-17 13:27:08 -05:00
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
|
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
2022-12-03 19:16:03 -06:00
|
|
|
import type { DbQueue, DeliverQueue, EndedPollNotificationQueue, InboxQueue, ObjectStorageQueue, SystemQueue, WebhookDeliverQueue } from '@/core/QueueModule.js';
|
2019-03-07 22:03:38 -06:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
tags: ['admin'],
|
|
|
|
|
2022-01-18 07:27:10 -06:00
|
|
|
requireCredential: true,
|
2019-03-07 22:03:38 -06:00
|
|
|
requireModerator: true,
|
|
|
|
|
2021-03-06 07:34:11 -06:00
|
|
|
res: {
|
2022-01-18 07:27:10 -06:00
|
|
|
type: 'object',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 07:34:11 -06:00
|
|
|
properties: {
|
|
|
|
deliver: {
|
2022-01-18 07:27:10 -06:00
|
|
|
optional: false, nullable: false,
|
2021-12-09 08:58:30 -06:00
|
|
|
ref: 'QueueCount',
|
2021-03-06 07:34:11 -06:00
|
|
|
},
|
|
|
|
inbox: {
|
2022-01-18 07:27:10 -06:00
|
|
|
optional: false, nullable: false,
|
2021-12-09 08:58:30 -06:00
|
|
|
ref: 'QueueCount',
|
2021-03-06 07:34:11 -06:00
|
|
|
},
|
|
|
|
db: {
|
2022-01-18 07:27:10 -06:00
|
|
|
optional: false, nullable: false,
|
2021-12-09 08:58:30 -06:00
|
|
|
ref: 'QueueCount',
|
2021-03-06 07:34:11 -06:00
|
|
|
},
|
|
|
|
objectStorage: {
|
2022-01-18 07:27:10 -06:00
|
|
|
optional: false, nullable: false,
|
2021-12-09 08:58:30 -06:00
|
|
|
ref: 'QueueCount',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-01-18 07:27:10 -06:00
|
|
|
} as const;
|
2019-03-07 22:03:38 -06:00
|
|
|
|
2022-02-19 22:15:40 -06:00
|
|
|
export const paramDef = {
|
2022-02-18 23:05:32 -06:00
|
|
|
type: 'object',
|
|
|
|
properties: {},
|
|
|
|
required: [],
|
|
|
|
} as const;
|
|
|
|
|
2022-01-02 11:12:50 -06:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2022-09-17 13:27:08 -05:00
|
|
|
@Injectable()
|
|
|
|
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|
|
|
constructor(
|
|
|
|
@Inject('queue:system') public systemQueue: SystemQueue,
|
|
|
|
@Inject('queue:endedPollNotification') public endedPollNotificationQueue: EndedPollNotificationQueue,
|
|
|
|
@Inject('queue:deliver') public deliverQueue: DeliverQueue,
|
|
|
|
@Inject('queue:inbox') public inboxQueue: InboxQueue,
|
|
|
|
@Inject('queue:db') public dbQueue: DbQueue,
|
|
|
|
@Inject('queue:objectStorage') public objectStorageQueue: ObjectStorageQueue,
|
|
|
|
@Inject('queue:webhookDeliver') public webhookDeliverQueue: WebhookDeliverQueue,
|
|
|
|
) {
|
|
|
|
super(meta, paramDef, async (ps, me) => {
|
|
|
|
const deliverJobCounts = await this.deliverQueue.getJobCounts();
|
|
|
|
const inboxJobCounts = await this.inboxQueue.getJobCounts();
|
|
|
|
const dbJobCounts = await this.dbQueue.getJobCounts();
|
|
|
|
const objectStorageJobCounts = await this.objectStorageQueue.getJobCounts();
|
2019-03-07 22:03:38 -06:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
return {
|
|
|
|
deliver: deliverJobCounts,
|
|
|
|
inbox: inboxJobCounts,
|
|
|
|
db: dbJobCounts,
|
|
|
|
objectStorage: objectStorageJobCounts,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|