]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/server/debug.ts
Resumable video uploads (#3933)
[github/Chocobozzz/PeerTube.git] / server / controllers / api / server / debug.ts
index 7787186beb94e21487a00529af7529d6a7ca16ce..ff0d9ca3caf070370fe6036dbce19a2b6b62d7f2 100644 (file)
@@ -1,4 +1,6 @@
 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 { authenticate, ensureUserHasRight } from '../../../middlewares'
@@ -11,6 +13,12 @@ debugRouter.get('/debug',
   getDebug
 )
 
+debugRouter.post('/debug/run-command',
+  authenticate,
+  ensureUserHasRight(UserRight.MANAGE_DEBUG),
+  runCommand
+)
+
 // ---------------------------------------------------------------------------
 
 export {
@@ -25,3 +33,13 @@ function getDebug (req: express.Request, res: express.Response) {
     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)
+}