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