diff options
Diffstat (limited to 'server/controllers/api/videos.js')
-rw-r--r-- | server/controllers/api/videos.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/server/controllers/api/videos.js b/server/controllers/api/videos.js index 5e9ff482f..1f7d30eef 100644 --- a/server/controllers/api/videos.js +++ b/server/controllers/api/videos.js | |||
@@ -93,11 +93,13 @@ router.get('/:id', | |||
93 | validatorsVideos.videosGet, | 93 | validatorsVideos.videosGet, |
94 | getVideo | 94 | getVideo |
95 | ) | 95 | ) |
96 | |||
96 | router.delete('/:id', | 97 | router.delete('/:id', |
97 | oAuth.authenticate, | 98 | oAuth.authenticate, |
98 | validatorsVideos.videosRemove, | 99 | validatorsVideos.videosRemove, |
99 | removeVideo | 100 | removeVideo |
100 | ) | 101 | ) |
102 | |||
101 | router.get('/search/:value', | 103 | router.get('/search/:value', |
102 | validatorsVideos.videosSearch, | 104 | validatorsVideos.videosSearch, |
103 | validatorsPagination.pagination, | 105 | validatorsPagination.pagination, |
@@ -108,6 +110,13 @@ router.get('/search/:value', | |||
108 | searchVideos | 110 | searchVideos |
109 | ) | 111 | ) |
110 | 112 | ||
113 | router.post('/:id/blacklist', | ||
114 | oAuth.authenticate, | ||
115 | admin.ensureIsAdmin, | ||
116 | validatorsVideos.videosBlacklist, | ||
117 | addVideoToBlacklist | ||
118 | ) | ||
119 | |||
111 | // --------------------------------------------------------------------------- | 120 | // --------------------------------------------------------------------------- |
112 | 121 | ||
113 | module.exports = router | 122 | module.exports = router |
@@ -622,3 +631,19 @@ function reportVideoAbuse (req, res, finalCallback) { | |||
622 | return finalCallback(null) | 631 | return finalCallback(null) |
623 | }) | 632 | }) |
624 | } | 633 | } |
634 | |||
635 | function addVideoToBlacklist (req, res, next) { | ||
636 | const videoInstance = res.locals.video | ||
637 | |||
638 | db.BlacklistedVideo.create({ | ||
639 | videoId: videoInstance.id | ||
640 | }) | ||
641 | .asCallback(function (err) { | ||
642 | if (err) { | ||
643 | logger.error('Errors when blacklisting video ', { error: err }) | ||
644 | return next(err) | ||
645 | } | ||
646 | |||
647 | return res.type('json').status(204).end() | ||
648 | }) | ||
649 | } | ||