1 // import * as express from 'express'
2 // import { logger, getFormattedObjects } from '../../../helpers'
6 // videosBlacklistAddValidator,
7 // videosBlacklistRemoveValidator,
8 // paginationValidator,
9 // blacklistSortValidator,
13 // } from '../../../middlewares'
14 // import { BlacklistedVideo, UserRight } from '../../../../shared'
15 // import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
17 // const videoCommentRouter = express.Router()
19 // videoCommentRouter.get('/:videoId/comment',
21 // ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),
22 // asyncMiddleware(listVideoCommentsThreadsValidator),
23 // asyncMiddleware(listVideoCommentsThreads)
26 // videoCommentRouter.post('/:videoId/comment',
28 // ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),
29 // asyncMiddleware(videosBlacklistAddValidator),
30 // asyncMiddleware(addVideoToBlacklist)
33 // videoCommentRouter.get('/blacklist',
35 // ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),
36 // paginationValidator,
37 // blacklistSortValidator,
40 // asyncMiddleware(listBlacklist)
43 // videoCommentRouter.delete('/:videoId/blacklist',
45 // ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),
46 // asyncMiddleware(videosBlacklistRemoveValidator),
47 // asyncMiddleware(removeVideoFromBlacklistController)
50 // // ---------------------------------------------------------------------------
56 // // ---------------------------------------------------------------------------
58 // async function addVideoToBlacklist (req: express.Request, res: express.Response, next: express.NextFunction) {
59 // const videoInstance = res.locals.video
62 // videoId: videoInstance.id
65 // await VideoBlacklistModel.create(toCreate)
66 // return res.type('json').status(204).end()
69 // async function listBlacklist (req: express.Request, res: express.Response, next: express.NextFunction) {
70 // const resultList = await VideoBlacklistModel.listForApi(req.query.start, req.query.count, req.query.sort)
72 // return res.json(getFormattedObjects<BlacklistedVideo, VideoBlacklistModel>(resultList.data, resultList.total))
75 // async function removeVideoFromBlacklistController (req: express.Request, res: express.Response, next: express.NextFunction) {
76 // const blacklistedVideo = res.locals.blacklistedVideo as VideoBlacklistModel
79 // await blacklistedVideo.destroy()
81 // logger.info('Video %s removed from blacklist.', res.locals.video.uuid)
83 // return res.sendStatus(204)
85 // logger.error('Some error while removing video %s from blacklist.', res.locals.video.uuid, err)