]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/videos/blacklist.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / server / controllers / api / videos / blacklist.ts
index fa8448c864a1976c69cad3168303e4a5ad079fa6..4103bb0630793b7f5edf3c521f46c821b004cb22 100644 (file)
@@ -1,6 +1,6 @@
-import * as express from 'express'
+import express from 'express'
 import { blacklistVideo, unblacklistVideo } from '@server/lib/video-blacklist'
-import { UserRight, VideoBlacklistCreate } from '../../../../shared'
+import { HttpStatusCode, UserRight, VideoBlacklistCreate } from '@shared/models'
 import { logger } from '../../../helpers/logger'
 import { getFormattedObjects } from '../../../helpers/utils'
 import { sequelizeTypescript } from '../../../initializers/database'
@@ -9,6 +9,7 @@ import {
   authenticate,
   blacklistSortValidator,
   ensureUserHasRight,
+  openapiOperationDoc,
   paginationValidator,
   setBlacklistSort,
   setDefaultPagination,
@@ -18,11 +19,11 @@ import {
   videosBlacklistUpdateValidator
 } from '../../../middlewares'
 import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
 
 const blacklistRouter = express.Router()
 
 blacklistRouter.post('/:videoId/blacklist',
+  openapiOperationDoc({ operationId: 'addVideoBlock' }),
   authenticate,
   ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),
   asyncMiddleware(videosBlacklistAddValidator),
@@ -30,6 +31,7 @@ blacklistRouter.post('/:videoId/blacklist',
 )
 
 blacklistRouter.get('/blacklist',
+  openapiOperationDoc({ operationId: 'getVideoBlocks' }),
   authenticate,
   ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),
   paginationValidator,
@@ -48,6 +50,7 @@ blacklistRouter.put('/:videoId/blacklist',
 )
 
 blacklistRouter.delete('/:videoId/blacklist',
+  openapiOperationDoc({ operationId: 'delVideoBlock' }),
   authenticate,
   ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),
   asyncMiddleware(videosBlacklistRemoveValidator),
@@ -70,7 +73,7 @@ async function addVideoToBlacklistController (req: express.Request, res: express
 
   logger.info('Video %s blacklisted.', videoInstance.uuid)
 
-  return res.type('json').sendStatus(HttpStatusCode.NO_CONTENT_204)
+  return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
 }
 
 async function updateVideoBlacklistController (req: express.Request, res: express.Response) {
@@ -82,7 +85,7 @@ async function updateVideoBlacklistController (req: express.Request, res: expres
     return videoBlacklist.save({ transaction: t })
   })
 
-  return res.type('json').sendStatus(HttpStatusCode.NO_CONTENT_204)
+  return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
 }
 
 async function listBlacklist (req: express.Request, res: express.Response) {
@@ -105,5 +108,5 @@ async function removeVideoFromBlacklistController (req: express.Request, res: ex
 
   logger.info('Video %s removed from blacklist.', video.uuid)
 
-  return res.type('json').sendStatus(HttpStatusCode.NO_CONTENT_204)
+  return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
 }