blob: 4b42fc2d703c17a3eb867f2db8b5f4fd4166a15d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import * as express from 'express'
import { database as db } from '../../../initializers/database'
import { logger } from '../../../helpers'
import {
authenticate,
ensureIsAdmin,
videosBlacklistValidator
} from '../../../middlewares'
const blacklistRouter = express.Router()
blacklistRouter.post('/:id/blacklist',
authenticate,
ensureIsAdmin,
videosBlacklistValidator,
addVideoToBlacklist
)
// ---------------------------------------------------------------------------
export {
blacklistRouter
}
// ---------------------------------------------------------------------------
function addVideoToBlacklist (req: express.Request, res: express.Response, next: express.NextFunction) {
const videoInstance = res.locals.video
const toCreate = {
videoId: videoInstance.id
}
db.BlacklistedVideo.create(toCreate).asCallback(function (err) {
if (err) {
logger.error('Errors when blacklisting video ', { error: err })
return next(err)
}
return res.type('json').status(204).end()
})
}
|