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/index.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/index.ts')
-rw-r--r-- | server/controllers/api/videos/index.ts | 10 |
1 files changed, 9 insertions, 1 deletions
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()), |