res.sendStatus(500)
}
})
+
+ router.get('/server-config', async (req, res) => {
+ const serverConfig = await peertubeHelpers.config.getServerConfig()
+
+ return res.json({ serverConfig })
+ })
+
+ router.get('/server-listening-config', async (req, res) => {
+ const config = await peertubeHelpers.config.getServerListeningConfig()
+
+ return res.json({ config })
+ })
+
+ router.get('/static-route', async (req, res) => {
+ const staticRoute = peertubeHelpers.plugin.getBaseStaticRoute()
+
+ return res.json({ staticRoute })
+ })
+
+ router.get('/router-route', async (req, res) => {
+ const routerRoute = peertubeHelpers.plugin.getBaseRouterRoute()
+
+ return res.json({ routerRoute })
+ })
+
+ router.get('/user/:id', async (req, res) => {
+ const user = await peertubeHelpers.user.loadById(req.params.id)
+ if (!user) return res.status(404).end()
+
+ return res.json({
+ username: user.username
+ })
+ })
+
+ router.get('/user', async (req, res) => {
+ const user = await peertubeHelpers.user.getAuthUser(res)
+ if (!user) return res.sendStatus(404)
+
+ const isAdmin = user.role === 0
+ const isModerator = user.role === 1
+ const isUser = user.role === 2
+
+ return res.json({
+ id: user.id,
+ username: user.username,
+ displayName: user.Account.name,
+ isAdmin,
+ isModerator,
+ isUser
+ })
+ })
+
+ router.get('/video-files/:id', async (req, res) => {
+ const details = await peertubeHelpers.videos.getFiles(req.params.id)
+ if (!details) return res.sendStatus(404)
+
+ return res.json(details)
+ })
+
+ router.get('/ffprobe', async (req, res) => {
+ const result = await peertubeHelpers.videos.ffprobe(req.query.path)
+ if (!result) return res.sendStatus(404)
+
+ return res.json(result)
+ })
+
+ router.post('/send-notification', async (req, res) => {
+ peertubeHelpers.socket.sendNotification(req.body.userId, {
+ type: 1,
+ userId: req.body.userId
+ })
+
+ return res.sendStatus(201)
+ })
+
+ router.post('/send-video-live-new-state/:uuid', async (req, res) => {
+ const video = await peertubeHelpers.videos.loadByIdOrUUID(req.params.uuid)
+ peertubeHelpers.socket.sendVideoLiveNewState(video)
+
+ return res.sendStatus(201)
+ })
}
+
}
async function unregister () {