From 299474e8279675adb6c5ce140e7e39c6f3439453 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 2 Aug 2018 16:33:29 +0200 Subject: Add ability to remove a video import --- server/controllers/api/videos/import.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'server/controllers/api/videos') diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 9761cdbcf..680d8665f 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts @@ -41,7 +41,7 @@ videoImportsRouter.post('/imports', videoImportsRouter.delete('/imports/:id', authenticate, - videoImportDeleteValidator, + asyncMiddleware(videoImportDeleteValidator), asyncRetryTransactionMiddleware(deleteVideoImport) ) @@ -147,5 +147,13 @@ async function addVideoImport (req: express.Request, res: express.Response) { } async function deleteVideoImport (req: express.Request, res: express.Response) { - // TODO: delete video import + await sequelizeTypescript.transaction(async t => { + const videoImport = res.locals.videoImport + const video = videoImport.Video + + await videoImport.destroy({ transaction: t }) + await video.destroy({ transaction: t }) + }) + + return res.status(204).end() } -- cgit v1.2.3