]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/controllers/api/server/debug.ts
Resumable video uploads (#3933)
[github/Chocobozzz/PeerTube.git] / server / controllers / api / server / debug.ts
CommitLineData
fae6e4da 1import { InboxManager } from '@server/lib/activitypub/inbox-manager'
f6d6e7f8 2import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler'
3import { SendDebugCommand } from '@shared/models'
5d79474c
C
4import * as express from 'express'
5import { UserRight } from '../../../../shared/models/users'
a1587156 6import { authenticate, ensureUserHasRight } from '../../../middlewares'
5d79474c
C
7
8const debugRouter = express.Router()
9
10debugRouter.get('/debug',
11 authenticate,
12 ensureUserHasRight(UserRight.MANAGE_DEBUG),
a1587156 13 getDebug
5d79474c
C
14)
15
f6d6e7f8 16debugRouter.post('/debug/run-command',
17 authenticate,
18 ensureUserHasRight(UserRight.MANAGE_DEBUG),
19 runCommand
20)
21
5d79474c
C
22// ---------------------------------------------------------------------------
23
24export {
25 debugRouter
26}
27
28// ---------------------------------------------------------------------------
29
a1587156 30function getDebug (req: express.Request, res: express.Response) {
5d79474c 31 return res.json({
fae6e4da
C
32 ip: req.ip,
33 activityPubMessagesWaiting: InboxManager.Instance.getActivityPubMessagesWaiting()
34 })
5d79474c 35}
f6d6e7f8 36
37async function runCommand (req: express.Request, res: express.Response) {
38 const body: SendDebugCommand = req.body
39
40 if (body.command === 'remove-dandling-resumable-uploads') {
41 await RemoveDanglingResumableUploadsScheduler.Instance.execute()
42 }
43
44 return res.sendStatus(204)
45}