Add notification settings migration

This commit is contained in:
Chocobozzz
2018-12-28 13:47:17 +01:00
committed by Chocobozzz
parent cef534ed53
commit e8d246d526
7 changed files with 81 additions and 33 deletions

View File

@@ -264,7 +264,6 @@ async function addVideo (req: express.Request, res: express.Response) {
}
await federateVideoIfNeeded(video, true, t)
Notifier.Instance.notifyOnNewVideo(video)
auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON()))
logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid)
@@ -272,6 +271,8 @@ async function addVideo (req: express.Request, res: express.Response) {
return videoCreated
})
Notifier.Instance.notifyOnNewVideo(videoCreated)
if (video.state === VideoState.TO_TRANSCODE) {
// Put uuid because we don't have id auto incremented for now
const dataInput = {
@@ -311,10 +312,8 @@ async function updateVideo (req: express.Request, res: express.Response) {
}
try {
await sequelizeTypescript.transaction(async t => {
const sequelizeOptions = {
transaction: t
}
const videoInstanceUpdated = await sequelizeTypescript.transaction(async t => {
const sequelizeOptions = { transaction: t }
const oldVideoChannel = videoInstance.VideoChannel
if (videoInfoToUpdate.name !== undefined) videoInstance.set('name', videoInfoToUpdate.name)
@@ -367,17 +366,19 @@ async function updateVideo (req: express.Request, res: express.Response) {
const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE
await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t)
if (wasUnlistedVideo || wasPrivateVideo) {
Notifier.Instance.notifyOnNewVideo(videoInstanceUpdated)
}
auditLogger.update(
getAuditIdFromRes(res),
new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()),
oldVideoAuditView
)
logger.info('Video with name %s and uuid %s updated.', videoInstance.name, videoInstance.uuid)
return videoInstanceUpdated
})
if (wasUnlistedVideo || wasPrivateVideo) {
Notifier.Instance.notifyOnNewVideo(videoInstanceUpdated)
}
} catch (err) {
// Force fields we want to update
// If the transaction is retried, sequelize will think the object has not changed