From 5abb9fbbd12e7097e348d6a38622d364b1fa47ed Mon Sep 17 00:00:00 2001
From: Chocobozzz <me@florianbigard.com>
Date: Thu, 10 Jan 2019 15:39:51 +0100
Subject: Add ability to unfederate a local video (on blacklist)

---
 .../models/videos/blacklist/video-blacklist-create.model.ts   |  1 +
 shared/models/videos/blacklist/video-blacklist.model.ts       |  1 +
 shared/utils/server/servers.ts                                |  4 ++++
 shared/utils/videos/video-blacklist.ts                        | 11 +++++++++--
 4 files changed, 15 insertions(+), 2 deletions(-)

(limited to 'shared')

diff --git a/shared/models/videos/blacklist/video-blacklist-create.model.ts b/shared/models/videos/blacklist/video-blacklist-create.model.ts
index 89c69cb56..6e7d36421 100644
--- a/shared/models/videos/blacklist/video-blacklist-create.model.ts
+++ b/shared/models/videos/blacklist/video-blacklist-create.model.ts
@@ -1,3 +1,4 @@
 export interface VideoBlacklistCreate {
   reason?: string
+  unfederate?: boolean
 }
diff --git a/shared/models/videos/blacklist/video-blacklist.model.ts b/shared/models/videos/blacklist/video-blacklist.model.ts
index ef4e5e3a2..4bd976190 100644
--- a/shared/models/videos/blacklist/video-blacklist.model.ts
+++ b/shared/models/videos/blacklist/video-blacklist.model.ts
@@ -2,6 +2,7 @@ export interface VideoBlacklist {
   id: number
   createdAt: Date
   updatedAt: Date
+  unfederated: boolean
   reason?: string
 
   video: {
diff --git a/shared/utils/server/servers.ts b/shared/utils/server/servers.ts
index 568385a41..1e9c83c72 100644
--- a/shared/utils/server/servers.ts
+++ b/shared/utils/server/servers.ts
@@ -145,8 +145,12 @@ function runServer (serverNumber: number, configOverride?: Object, args = []) {
       if (dontContinue === true) return
 
       server.app.stdout.removeListener('data', onStdout)
+
+      process.on('exit', () => process.kill(server.app.pid))
+
       res(server)
     })
+
   })
 }
 
diff --git a/shared/utils/videos/video-blacklist.ts b/shared/utils/videos/video-blacklist.ts
index 2c176fde0..f2ae0ed26 100644
--- a/shared/utils/videos/video-blacklist.ts
+++ b/shared/utils/videos/video-blacklist.ts
@@ -1,11 +1,18 @@
 import * as request from 'supertest'
 
-function addVideoToBlacklist (url: string, token: string, videoId: number | string, reason?: string, specialStatus = 204) {
+function addVideoToBlacklist (
+  url: string,
+  token: string,
+  videoId: number | string,
+  reason?: string,
+  unfederate?: boolean,
+  specialStatus = 204
+) {
   const path = '/api/v1/videos/' + videoId + '/blacklist'
 
   return request(url)
           .post(path)
-          .send({ reason })
+          .send({ reason, unfederate })
           .set('Accept', 'application/json')
           .set('Authorization', 'Bearer ' + token)
           .expect(specialStatus)
-- 
cgit v1.2.3