1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00
Peertube/server/controllers/api/videos/blacklist.ts
2017-05-25 17:32:16 +02:00

43 lines
981 B
TypeScript

import express = require('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, res, next) {
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()
})
}