diff options
author | Chocobozzz <me@florianbigard.com> | 2018-12-26 10:36:24 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-01-09 11:15:15 +0100 |
commit | cef534ed53e4518fe0acf581bfe880788d42fc36 (patch) | |
tree | 115b51ea5136849a2336d44915c7780649f25dc2 /server/controllers/api/videos/blacklist.ts | |
parent | 1de1d05f4c61fe059fa5e24e79c92582f0e7e4b3 (diff) | |
download | PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.tar.gz PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.tar.zst PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.zip |
Add user notification base code
Diffstat (limited to 'server/controllers/api/videos/blacklist.ts')
-rw-r--r-- | server/controllers/api/videos/blacklist.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index 7f803c8e9..9ef08812b 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts | |||
@@ -16,6 +16,8 @@ import { | |||
16 | } from '../../../middlewares' | 16 | } from '../../../middlewares' |
17 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' | 17 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' |
18 | import { sequelizeTypescript } from '../../../initializers' | 18 | import { sequelizeTypescript } from '../../../initializers' |
19 | import { Notifier } from '../../../lib/notifier' | ||
20 | import { VideoModel } from '../../../models/video/video' | ||
19 | 21 | ||
20 | const blacklistRouter = express.Router() | 22 | const blacklistRouter = express.Router() |
21 | 23 | ||
@@ -67,13 +69,18 @@ async function addVideoToBlacklist (req: express.Request, res: express.Response) | |||
67 | reason: body.reason | 69 | reason: body.reason |
68 | } | 70 | } |
69 | 71 | ||
70 | await VideoBlacklistModel.create(toCreate) | 72 | const blacklist = await VideoBlacklistModel.create(toCreate) |
73 | blacklist.Video = videoInstance | ||
74 | |||
75 | Notifier.Instance.notifyOnVideoBlacklist(blacklist) | ||
76 | |||
77 | logger.info('Video %s blacklisted.', res.locals.video.uuid) | ||
78 | |||
71 | return res.type('json').status(204).end() | 79 | return res.type('json').status(204).end() |
72 | } | 80 | } |
73 | 81 | ||
74 | async function updateVideoBlacklistController (req: express.Request, res: express.Response) { | 82 | async function updateVideoBlacklistController (req: express.Request, res: express.Response) { |
75 | const videoBlacklist = res.locals.videoBlacklist as VideoBlacklistModel | 83 | const videoBlacklist = res.locals.videoBlacklist as VideoBlacklistModel |
76 | logger.info(videoBlacklist) | ||
77 | 84 | ||
78 | if (req.body.reason !== undefined) videoBlacklist.reason = req.body.reason | 85 | if (req.body.reason !== undefined) videoBlacklist.reason = req.body.reason |
79 | 86 | ||
@@ -92,11 +99,14 @@ async function listBlacklist (req: express.Request, res: express.Response, next: | |||
92 | 99 | ||
93 | async function removeVideoFromBlacklistController (req: express.Request, res: express.Response, next: express.NextFunction) { | 100 | async function removeVideoFromBlacklistController (req: express.Request, res: express.Response, next: express.NextFunction) { |
94 | const videoBlacklist = res.locals.videoBlacklist as VideoBlacklistModel | 101 | const videoBlacklist = res.locals.videoBlacklist as VideoBlacklistModel |
102 | const video: VideoModel = res.locals.video | ||
95 | 103 | ||
96 | await sequelizeTypescript.transaction(t => { | 104 | await sequelizeTypescript.transaction(t => { |
97 | return videoBlacklist.destroy({ transaction: t }) | 105 | return videoBlacklist.destroy({ transaction: t }) |
98 | }) | 106 | }) |
99 | 107 | ||
108 | Notifier.Instance.notifyOnVideoUnblacklist(video) | ||
109 | |||
100 | logger.info('Video %s removed from blacklist.', res.locals.video.uuid) | 110 | logger.info('Video %s removed from blacklist.', res.locals.video.uuid) |
101 | 111 | ||
102 | return res.type('json').status(204).end() | 112 | return res.type('json').status(204).end() |