]>
Commit | Line | Data |
---|---|---|
fae6e4da | 1 | import { InboxManager } from '@server/lib/activitypub/inbox-manager' |
f6d6e7f8 | 2 | import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler' |
3 | import { SendDebugCommand } from '@shared/models' | |
5d79474c C |
4 | import * as express from 'express' |
5 | import { UserRight } from '../../../../shared/models/users' | |
a1587156 | 6 | import { authenticate, ensureUserHasRight } from '../../../middlewares' |
5d79474c C |
7 | |
8 | const debugRouter = express.Router() | |
9 | ||
10 | debugRouter.get('/debug', | |
11 | authenticate, | |
12 | ensureUserHasRight(UserRight.MANAGE_DEBUG), | |
a1587156 | 13 | getDebug |
5d79474c C |
14 | ) |
15 | ||
f6d6e7f8 | 16 | debugRouter.post('/debug/run-command', |
17 | authenticate, | |
18 | ensureUserHasRight(UserRight.MANAGE_DEBUG), | |
19 | runCommand | |
20 | ) | |
21 | ||
5d79474c C |
22 | // --------------------------------------------------------------------------- |
23 | ||
24 | export { | |
25 | debugRouter | |
26 | } | |
27 | ||
28 | // --------------------------------------------------------------------------- | |
29 | ||
a1587156 | 30 | function 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 | |
37 | async 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 | } |