From 2d53be0267acc49cda46707b885096193a1f4e9c Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Mon, 7 Dec 2020 14:32:36 +0100 Subject: replace numbers with typed http status codes (#3409) --- server/controllers/api/video-playlist.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'server/controllers/api/video-playlist.ts') diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index fb08a63b2..f3dc8b2a9 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts @@ -42,6 +42,7 @@ import { import { AccountModel } from '../../models/account/account' import { VideoPlaylistModel } from '../../models/video/video-playlist' import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' +import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) @@ -271,7 +272,7 @@ async function updateVideoPlaylist (req: express.Request, res: express.Response) throw err } - return res.type('json').status(204).end() + return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() } async function removeVideoPlaylist (req: express.Request, res: express.Response) { @@ -285,7 +286,7 @@ async function removeVideoPlaylist (req: express.Request, res: express.Response) logger.info('Video playlist %s deleted.', videoPlaylistInstance.uuid) }) - return res.type('json').status(204).end() + return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() } async function addVideoInPlaylist (req: express.Request, res: express.Response) { @@ -351,7 +352,7 @@ async function updateVideoPlaylistElement (req: express.Request, res: express.Re logger.info('Element of position %d of playlist %s updated.', playlistElement.position, videoPlaylist.uuid) - return res.type('json').status(204).end() + return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() } async function removeVideoFromPlaylist (req: express.Request, res: express.Response) { @@ -379,7 +380,7 @@ async function removeVideoFromPlaylist (req: express.Request, res: express.Respo sendUpdateVideoPlaylist(videoPlaylist, undefined) .catch(err => logger.error('Cannot send video playlist update.', { err })) - return res.type('json').status(204).end() + return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() } async function reorderVideosPlaylist (req: express.Request, res: express.Response) { @@ -391,7 +392,7 @@ async function reorderVideosPlaylist (req: express.Request, res: express.Respons const reorderLength: number = body.reorderLength || 1 if (start === insertAfter) { - return res.status(204).end() + return res.status(HttpStatusCode.NO_CONTENT_204).end() } // Example: if we reorder position 2 and insert after position 5 (so at position 6): # 1 2 3 4 5 6 7 8 9 @@ -432,7 +433,7 @@ async function reorderVideosPlaylist (req: express.Request, res: express.Respons videoPlaylist.uuid, insertAfter, start, start + reorderLength - 1 ) - return res.type('json').status(204).end() + return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() } async function getVideoPlaylistVideos (req: express.Request, res: express.Response) { -- cgit v1.2.3