aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r--server/controllers/api/videos/abuse.ts3
-rw-r--r--server/controllers/api/videos/blacklist.ts14
-rw-r--r--server/controllers/api/videos/comment.ts3
-rw-r--r--server/controllers/api/videos/index.ts10
4 files changed, 27 insertions, 3 deletions
diff --git a/server/controllers/api/videos/abuse.ts b/server/controllers/api/videos/abuse.ts
index d0c81804b..fe0a95cd5 100644
--- a/server/controllers/api/videos/abuse.ts
+++ b/server/controllers/api/videos/abuse.ts
@@ -22,6 +22,7 @@ import { VideoModel } from '../../../models/video/video'
22import { VideoAbuseModel } from '../../../models/video/video-abuse' 22import { VideoAbuseModel } from '../../../models/video/video-abuse'
23import { auditLoggerFactory, VideoAbuseAuditView } from '../../../helpers/audit-logger' 23import { auditLoggerFactory, VideoAbuseAuditView } from '../../../helpers/audit-logger'
24import { UserModel } from '../../../models/account/user' 24import { UserModel } from '../../../models/account/user'
25import { Notifier } from '../../../lib/notifier'
25 26
26const auditLogger = auditLoggerFactory('abuse') 27const auditLogger = auditLoggerFactory('abuse')
27const abuseVideoRouter = express.Router() 28const abuseVideoRouter = express.Router()
@@ -117,6 +118,8 @@ async function reportVideoAbuse (req: express.Request, res: express.Response) {
117 await sendVideoAbuse(reporterAccount.Actor, videoAbuseInstance, videoInstance) 118 await sendVideoAbuse(reporterAccount.Actor, videoAbuseInstance, videoInstance)
118 } 119 }
119 120
121 Notifier.Instance.notifyOnNewVideoAbuse(videoAbuseInstance)
122
120 auditLogger.create(reporterAccount.Actor.getIdentifier(), new VideoAbuseAuditView(videoAbuseInstance.toFormattedJSON())) 123 auditLogger.create(reporterAccount.Actor.getIdentifier(), new VideoAbuseAuditView(videoAbuseInstance.toFormattedJSON()))
121 124
122 return videoAbuseInstance 125 return videoAbuseInstance
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'
17import { VideoBlacklistModel } from '../../../models/video/video-blacklist' 17import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
18import { sequelizeTypescript } from '../../../initializers' 18import { sequelizeTypescript } from '../../../initializers'
19import { Notifier } from '../../../lib/notifier'
20import { VideoModel } from '../../../models/video/video'
19 21
20const blacklistRouter = express.Router() 22const 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
74async function updateVideoBlacklistController (req: express.Request, res: express.Response) { 82async 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
93async function removeVideoFromBlacklistController (req: express.Request, res: express.Response, next: express.NextFunction) { 100async 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()
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts
index 3875c8f79..70c1148ba 100644
--- a/server/controllers/api/videos/comment.ts
+++ b/server/controllers/api/videos/comment.ts
@@ -26,6 +26,7 @@ import { VideoCommentModel } from '../../../models/video/video-comment'
26import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' 26import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger'
27import { AccountModel } from '../../../models/account/account' 27import { AccountModel } from '../../../models/account/account'
28import { UserModel } from '../../../models/account/user' 28import { UserModel } from '../../../models/account/user'
29import { Notifier } from '../../../lib/notifier'
29 30
30const auditLogger = auditLoggerFactory('comments') 31const auditLogger = auditLoggerFactory('comments')
31const videoCommentRouter = express.Router() 32const videoCommentRouter = express.Router()
@@ -119,6 +120,7 @@ async function addVideoCommentThread (req: express.Request, res: express.Respons
119 }, t) 120 }, t)
120 }) 121 })
121 122
123 Notifier.Instance.notifyOnNewComment(comment)
122 auditLogger.create(getAuditIdFromRes(res), new CommentAuditView(comment.toFormattedJSON())) 124 auditLogger.create(getAuditIdFromRes(res), new CommentAuditView(comment.toFormattedJSON()))
123 125
124 return res.json({ 126 return res.json({
@@ -140,6 +142,7 @@ async function addVideoCommentReply (req: express.Request, res: express.Response
140 }, t) 142 }, t)
141 }) 143 })
142 144
145 Notifier.Instance.notifyOnNewComment(comment)
143 auditLogger.create(getAuditIdFromRes(res), new CommentAuditView(comment.toFormattedJSON())) 146 auditLogger.create(getAuditIdFromRes(res), new CommentAuditView(comment.toFormattedJSON()))
144 147
145 return res.json({ comment: comment.toFormattedJSON() }).end() 148 return res.json({ comment: comment.toFormattedJSON() }).end()
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 00a1302d1..94ed08fed 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -7,7 +7,8 @@ import { logger } from '../../../helpers/logger'
7import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' 7import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
8import { getFormattedObjects, getServerActor } from '../../../helpers/utils' 8import { getFormattedObjects, getServerActor } from '../../../helpers/utils'
9import { 9import {
10 CONFIG, MIMETYPES, 10 CONFIG,
11 MIMETYPES,
11 PREVIEWS_SIZE, 12 PREVIEWS_SIZE,
12 sequelizeTypescript, 13 sequelizeTypescript,
13 THUMBNAILS_SIZE, 14 THUMBNAILS_SIZE,
@@ -57,6 +58,7 @@ import { videoImportsRouter } from './import'
57import { resetSequelizeInstance } from '../../../helpers/database-utils' 58import { resetSequelizeInstance } from '../../../helpers/database-utils'
58import { move } from 'fs-extra' 59import { move } from 'fs-extra'
59import { watchingRouter } from './watching' 60import { watchingRouter } from './watching'
61import { Notifier } from '../../../lib/notifier'
60 62
61const auditLogger = auditLoggerFactory('videos') 63const auditLogger = auditLoggerFactory('videos')
62const videosRouter = express.Router() 64const videosRouter = express.Router()
@@ -262,6 +264,7 @@ async function addVideo (req: express.Request, res: express.Response) {
262 } 264 }
263 265
264 await federateVideoIfNeeded(video, true, t) 266 await federateVideoIfNeeded(video, true, t)
267 Notifier.Instance.notifyOnNewVideo(video)
265 268
266 auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON())) 269 auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON()))
267 logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid) 270 logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid)
@@ -293,6 +296,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
293 const oldVideoAuditView = new VideoAuditView(videoInstance.toFormattedDetailsJSON()) 296 const oldVideoAuditView = new VideoAuditView(videoInstance.toFormattedDetailsJSON())
294 const videoInfoToUpdate: VideoUpdate = req.body 297 const videoInfoToUpdate: VideoUpdate = req.body
295 const wasPrivateVideo = videoInstance.privacy === VideoPrivacy.PRIVATE 298 const wasPrivateVideo = videoInstance.privacy === VideoPrivacy.PRIVATE
299 const wasUnlistedVideo = videoInstance.privacy === VideoPrivacy.UNLISTED
296 300
297 // Process thumbnail or create it from the video 301 // Process thumbnail or create it from the video
298 if (req.files && req.files['thumbnailfile']) { 302 if (req.files && req.files['thumbnailfile']) {
@@ -363,6 +367,10 @@ async function updateVideo (req: express.Request, res: express.Response) {
363 const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE 367 const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE
364 await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t) 368 await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t)
365 369
370 if (wasUnlistedVideo || wasPrivateVideo) {
371 Notifier.Instance.notifyOnNewVideo(videoInstanceUpdated)
372 }
373
366 auditLogger.update( 374 auditLogger.update(
367 getAuditIdFromRes(res), 375 getAuditIdFromRes(res),
368 new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()), 376 new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()),