1 import * as express from 'express'
2 import { InboxManager } from '@server/lib/activitypub/inbox-manager'
3 import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler'
4 import { Debug, SendDebugCommand } from '@shared/models'
5 import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
6 import { UserRight } from '../../../../shared/models/users'
7 import { authenticate, ensureUserHasRight } from '../../../middlewares'
9 const debugRouter = express.Router()
11 debugRouter.get('/debug',
13 ensureUserHasRight(UserRight.MANAGE_DEBUG),
17 debugRouter.post('/debug/run-command',
19 ensureUserHasRight(UserRight.MANAGE_DEBUG),
23 // ---------------------------------------------------------------------------
29 // ---------------------------------------------------------------------------
31 function getDebug (req: express.Request, res: express.Response) {
34 activityPubMessagesWaiting: InboxManager.Instance.getActivityPubMessagesWaiting()
38 async function runCommand (req: express.Request, res: express.Response) {
39 const body: SendDebugCommand = req.body
41 if (body.command === 'remove-dandling-resumable-uploads') {
42 await RemoveDanglingResumableUploadsScheduler.Instance.execute()
45 return res.status(HttpStatusCode.NO_CONTENT_204).end()