diff options
Diffstat (limited to 'server/controllers/api/videos/blacklist.ts')
-rw-r--r-- | server/controllers/api/videos/blacklist.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index 9ef08812b..43b0516e7 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts | |||
@@ -18,6 +18,8 @@ import { VideoBlacklistModel } from '../../../models/video/video-blacklist' | |||
18 | import { sequelizeTypescript } from '../../../initializers' | 18 | import { sequelizeTypescript } from '../../../initializers' |
19 | import { Notifier } from '../../../lib/notifier' | 19 | import { Notifier } from '../../../lib/notifier' |
20 | import { VideoModel } from '../../../models/video/video' | 20 | import { VideoModel } from '../../../models/video/video' |
21 | import { sendCreateVideo, sendDeleteVideo, sendUpdateVideo } from '../../../lib/activitypub/send' | ||
22 | import { federateVideoIfNeeded } from '../../../lib/activitypub' | ||
21 | 23 | ||
22 | const blacklistRouter = express.Router() | 24 | const blacklistRouter = express.Router() |
23 | 25 | ||
@@ -66,12 +68,17 @@ async function addVideoToBlacklist (req: express.Request, res: express.Response) | |||
66 | 68 | ||
67 | const toCreate = { | 69 | const toCreate = { |
68 | videoId: videoInstance.id, | 70 | videoId: videoInstance.id, |
71 | unfederated: body.unfederate === true, | ||
69 | reason: body.reason | 72 | reason: body.reason |
70 | } | 73 | } |
71 | 74 | ||
72 | const blacklist = await VideoBlacklistModel.create(toCreate) | 75 | const blacklist = await VideoBlacklistModel.create(toCreate) |
73 | blacklist.Video = videoInstance | 76 | blacklist.Video = videoInstance |
74 | 77 | ||
78 | if (body.unfederate === true) { | ||
79 | await sendDeleteVideo(videoInstance, undefined) | ||
80 | } | ||
81 | |||
75 | Notifier.Instance.notifyOnVideoBlacklist(blacklist) | 82 | Notifier.Instance.notifyOnVideoBlacklist(blacklist) |
76 | 83 | ||
77 | logger.info('Video %s blacklisted.', res.locals.video.uuid) | 84 | logger.info('Video %s blacklisted.', res.locals.video.uuid) |
@@ -101,8 +108,14 @@ async function removeVideoFromBlacklistController (req: express.Request, res: ex | |||
101 | const videoBlacklist = res.locals.videoBlacklist as VideoBlacklistModel | 108 | const videoBlacklist = res.locals.videoBlacklist as VideoBlacklistModel |
102 | const video: VideoModel = res.locals.video | 109 | const video: VideoModel = res.locals.video |
103 | 110 | ||
104 | await sequelizeTypescript.transaction(t => { | 111 | await sequelizeTypescript.transaction(async t => { |
105 | return videoBlacklist.destroy({ transaction: t }) | 112 | const unfederated = videoBlacklist.unfederated |
113 | await videoBlacklist.destroy({ transaction: t }) | ||
114 | |||
115 | // Re federate the video | ||
116 | if (unfederated === true) { | ||
117 | await federateVideoIfNeeded(video, true, t) | ||
118 | } | ||
106 | }) | 119 | }) |
107 | 120 | ||
108 | Notifier.Instance.notifyOnVideoUnblacklist(video) | 121 | Notifier.Instance.notifyOnVideoUnblacklist(video) |