1 import { InboxManager } from '@server/lib/activitypub/inbox-manager'
2 import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler'
3 import { SendDebugCommand } from '@shared/models'
4 import * as express from 'express'
5 import { UserRight } from '../../../../shared/models/users'
6 import { authenticate, ensureUserHasRight } from '../../../middlewares'
8 const debugRouter = express.Router()
10 debugRouter.get('/debug',
12 ensureUserHasRight(UserRight.MANAGE_DEBUG),
16 debugRouter.post('/debug/run-command',
18 ensureUserHasRight(UserRight.MANAGE_DEBUG),
22 // ---------------------------------------------------------------------------
28 // ---------------------------------------------------------------------------
30 function getDebug (req: express.Request, res: express.Response) {
33 activityPubMessagesWaiting: InboxManager.Instance.getActivityPubMessagesWaiting()
37 async function runCommand (req: express.Request, res: express.Response) {
38 const body: SendDebugCommand = req.body
40 if (body.command === 'remove-dandling-resumable-uploads') {
41 await RemoveDanglingResumableUploadsScheduler.Instance.execute()
44 return res.sendStatus(204)