diff options
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/abuse.ts | 3 | ||||
-rw-r--r-- | server/controllers/api/videos/blacklist.ts | 14 | ||||
-rw-r--r-- | server/controllers/api/videos/comment.ts | 3 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 10 |
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' | |||
22 | import { VideoAbuseModel } from '../../../models/video/video-abuse' | 22 | import { VideoAbuseModel } from '../../../models/video/video-abuse' |
23 | import { auditLoggerFactory, VideoAbuseAuditView } from '../../../helpers/audit-logger' | 23 | import { auditLoggerFactory, VideoAbuseAuditView } from '../../../helpers/audit-logger' |
24 | import { UserModel } from '../../../models/account/user' | 24 | import { UserModel } from '../../../models/account/user' |
25 | import { Notifier } from '../../../lib/notifier' | ||
25 | 26 | ||
26 | const auditLogger = auditLoggerFactory('abuse') | 27 | const auditLogger = auditLoggerFactory('abuse') |
27 | const abuseVideoRouter = express.Router() | 28 | const 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' |
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() |
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' | |||
26 | import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' | 26 | import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' |
27 | import { AccountModel } from '../../../models/account/account' | 27 | import { AccountModel } from '../../../models/account/account' |
28 | import { UserModel } from '../../../models/account/user' | 28 | import { UserModel } from '../../../models/account/user' |
29 | import { Notifier } from '../../../lib/notifier' | ||
29 | 30 | ||
30 | const auditLogger = auditLoggerFactory('comments') | 31 | const auditLogger = auditLoggerFactory('comments') |
31 | const videoCommentRouter = express.Router() | 32 | const 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' | |||
7 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 7 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
8 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' | 8 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' |
9 | import { | 9 | import { |
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' | |||
57 | import { resetSequelizeInstance } from '../../../helpers/database-utils' | 58 | import { resetSequelizeInstance } from '../../../helpers/database-utils' |
58 | import { move } from 'fs-extra' | 59 | import { move } from 'fs-extra' |
59 | import { watchingRouter } from './watching' | 60 | import { watchingRouter } from './watching' |
61 | import { Notifier } from '../../../lib/notifier' | ||
60 | 62 | ||
61 | const auditLogger = auditLoggerFactory('videos') | 63 | const auditLogger = auditLoggerFactory('videos') |
62 | const videosRouter = express.Router() | 64 | const 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()), |