diff options
Diffstat (limited to 'server/controllers/static.ts')
-rw-r--r-- | server/controllers/static.ts | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/server/controllers/static.ts b/server/controllers/static.ts index e04c27b11..ff77452dd 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts | |||
@@ -26,6 +26,7 @@ import { MVideoFile, MVideoFullLight } from '@server/types/models' | |||
26 | import { getTorrentFilePath, getVideoFilePath } from '@server/lib/video-paths' | 26 | import { getTorrentFilePath, getVideoFilePath } from '@server/lib/video-paths' |
27 | import { getThemeOrDefault } from '../lib/plugins/theme-utils' | 27 | import { getThemeOrDefault } from '../lib/plugins/theme-utils' |
28 | import { getEnabledResolutions, getRegisteredPlugins, getRegisteredThemes } from '@server/controllers/api/config' | 28 | import { getEnabledResolutions, getRegisteredPlugins, getRegisteredThemes } from '@server/controllers/api/config' |
29 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | ||
29 | 30 | ||
30 | const staticRouter = express.Router() | 31 | const staticRouter = express.Router() |
31 | 32 | ||
@@ -121,7 +122,7 @@ staticRouter.get('/robots.txt', | |||
121 | // security.txt service | 122 | // security.txt service |
122 | staticRouter.get('/security.txt', | 123 | staticRouter.get('/security.txt', |
123 | (_, res: express.Response) => { | 124 | (_, res: express.Response) => { |
124 | return res.redirect(301, '/.well-known/security.txt') | 125 | return res.redirect(HttpStatusCode.MOVED_PERMANENTLY_301, '/.well-known/security.txt') |
125 | } | 126 | } |
126 | ) | 127 | ) |
127 | 128 | ||
@@ -331,7 +332,7 @@ async function generateNodeinfo (req: express.Request, res: express.Response) { | |||
331 | res.contentType('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"') | 332 | res.contentType('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"') |
332 | } else { | 333 | } else { |
333 | json = { error: 'Nodeinfo schema version not handled' } | 334 | json = { error: 'Nodeinfo schema version not handled' } |
334 | res.status(404) | 335 | res.status(HttpStatusCode.NOT_FOUND_404) |
335 | } | 336 | } |
336 | 337 | ||
337 | return res.send(json).end() | 338 | return res.send(json).end() |
@@ -341,7 +342,7 @@ function downloadTorrent (req: express.Request, res: express.Response) { | |||
341 | const video = res.locals.videoAll | 342 | const video = res.locals.videoAll |
342 | 343 | ||
343 | const videoFile = getVideoFile(req, video.VideoFiles) | 344 | const videoFile = getVideoFile(req, video.VideoFiles) |
344 | if (!videoFile) return res.status(404).end() | 345 | if (!videoFile) return res.status(HttpStatusCode.NOT_FOUND_404).end() |
345 | 346 | ||
346 | return res.download(getTorrentFilePath(video, videoFile), `${video.name}-${videoFile.resolution}p.torrent`) | 347 | return res.download(getTorrentFilePath(video, videoFile), `${video.name}-${videoFile.resolution}p.torrent`) |
347 | } | 348 | } |
@@ -350,10 +351,10 @@ function downloadHLSVideoFileTorrent (req: express.Request, res: express.Respons | |||
350 | const video = res.locals.videoAll | 351 | const video = res.locals.videoAll |
351 | 352 | ||
352 | const playlist = getHLSPlaylist(video) | 353 | const playlist = getHLSPlaylist(video) |
353 | if (!playlist) return res.status(404).end | 354 | if (!playlist) return res.status(HttpStatusCode.NOT_FOUND_404).end |
354 | 355 | ||
355 | const videoFile = getVideoFile(req, playlist.VideoFiles) | 356 | const videoFile = getVideoFile(req, playlist.VideoFiles) |
356 | if (!videoFile) return res.status(404).end() | 357 | if (!videoFile) return res.status(HttpStatusCode.NOT_FOUND_404).end() |
357 | 358 | ||
358 | return res.download(getTorrentFilePath(playlist, videoFile), `${video.name}-${videoFile.resolution}p-hls.torrent`) | 359 | return res.download(getTorrentFilePath(playlist, videoFile), `${video.name}-${videoFile.resolution}p-hls.torrent`) |
359 | } | 360 | } |
@@ -362,7 +363,7 @@ function downloadVideoFile (req: express.Request, res: express.Response) { | |||
362 | const video = res.locals.videoAll | 363 | const video = res.locals.videoAll |
363 | 364 | ||
364 | const videoFile = getVideoFile(req, video.VideoFiles) | 365 | const videoFile = getVideoFile(req, video.VideoFiles) |
365 | if (!videoFile) return res.status(404).end() | 366 | if (!videoFile) return res.status(HttpStatusCode.NOT_FOUND_404).end() |
366 | 367 | ||
367 | return res.download(getVideoFilePath(video, videoFile), `${video.name}-${videoFile.resolution}p${videoFile.extname}`) | 368 | return res.download(getVideoFilePath(video, videoFile), `${video.name}-${videoFile.resolution}p${videoFile.extname}`) |
368 | } | 369 | } |
@@ -370,10 +371,10 @@ function downloadVideoFile (req: express.Request, res: express.Response) { | |||
370 | function downloadHLSVideoFile (req: express.Request, res: express.Response) { | 371 | function downloadHLSVideoFile (req: express.Request, res: express.Response) { |
371 | const video = res.locals.videoAll | 372 | const video = res.locals.videoAll |
372 | const playlist = getHLSPlaylist(video) | 373 | const playlist = getHLSPlaylist(video) |
373 | if (!playlist) return res.status(404).end | 374 | if (!playlist) return res.status(HttpStatusCode.NOT_FOUND_404).end |
374 | 375 | ||
375 | const videoFile = getVideoFile(req, playlist.VideoFiles) | 376 | const videoFile = getVideoFile(req, playlist.VideoFiles) |
376 | if (!videoFile) return res.status(404).end() | 377 | if (!videoFile) return res.status(HttpStatusCode.NOT_FOUND_404).end() |
377 | 378 | ||
378 | const filename = `${video.name}-${videoFile.resolution}p-${playlist.getStringType()}${videoFile.extname}` | 379 | const filename = `${video.name}-${videoFile.resolution}p-${playlist.getStringType()}${videoFile.extname}` |
379 | return res.download(getVideoFilePath(playlist, videoFile), filename) | 380 | return res.download(getVideoFilePath(playlist, videoFile), filename) |