]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/videos/blacklist.ts
Async signature and various fixes
[github/Chocobozzz/PeerTube.git] / server / controllers / api / videos / blacklist.ts
index fb4d57d7ba6077b200d32b52104298997b4d00e1..e4be6f0f9cb8d11d7763dfbd4a7d1633e50ba946 100644 (file)
@@ -1,4 +1,4 @@
-import express = require('express')
+import * as express from 'express'
 
 import { database as db } from '../../../initializers/database'
 import { logger } from '../../../helpers'
@@ -25,19 +25,17 @@ export {
 
 // ---------------------------------------------------------------------------
 
-function addVideoToBlacklist (req, res, next) {
+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) {
+  db.BlacklistedVideo.create(toCreate)
+    .then(() => res.type('json').status(204).end())
+    .catch(err => {
       logger.error('Errors when blacklisting video ', { error: err })
       return next(err)
-    }
-
-    return res.type('json').status(204).end()
-  })
+    })
 }