+import { InboxManager } from '@server/lib/activitypub/inbox-manager'
+import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler'
+import { SendDebugCommand } from '@shared/models'
import * as express from 'express'
import { UserRight } from '../../../../shared/models/users'
-import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares'
+import { authenticate, ensureUserHasRight } from '../../../middlewares'
const debugRouter = express.Router()
debugRouter.get('/debug',
authenticate,
ensureUserHasRight(UserRight.MANAGE_DEBUG),
- asyncMiddleware(getDebug)
+ getDebug
+)
+
+debugRouter.post('/debug/run-command',
+ authenticate,
+ ensureUserHasRight(UserRight.MANAGE_DEBUG),
+ runCommand
)
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
-async function getDebug (req: express.Request, res: express.Response) {
+function getDebug (req: express.Request, res: express.Response) {
return res.json({
- ip: req.ip
- }).end()
+ ip: req.ip,
+ activityPubMessagesWaiting: InboxManager.Instance.getActivityPubMessagesWaiting()
+ })
+}
+
+async function runCommand (req: express.Request, res: express.Response) {
+ const body: SendDebugCommand = req.body
+
+ if (body.command === 'remove-dandling-resumable-uploads') {
+ await RemoveDanglingResumableUploadsScheduler.Instance.execute()
+ }
+
+ return res.sendStatus(204)
}