}
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)
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 = {
}
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)
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
// ---------------------------------------------------------------------------
-const LAST_MIGRATION_VERSION = 310
+const LAST_MIGRATION_VERSION = 315
// ---------------------------------------------------------------------------
--- /dev/null
+import * as Sequelize from 'sequelize'
+
+async function up (utils: {
+ transaction: Sequelize.Transaction,
+ queryInterface: Sequelize.QueryInterface,
+ sequelize: Sequelize.Sequelize
+}): Promise<void> {
+
+ {
+ const query = `
+CREATE TABLE IF NOT EXISTS "userNotificationSetting" ("id" SERIAL,
+"newVideoFromSubscription" INTEGER NOT NULL DEFAULT NULL,
+"newCommentOnMyVideo" INTEGER NOT NULL DEFAULT NULL,
+"videoAbuseAsModerator" INTEGER NOT NULL DEFAULT NULL,
+"blacklistOnMyVideo" INTEGER NOT NULL DEFAULT NULL,
+"userId" INTEGER REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL,
+"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL,
+PRIMARY KEY ("id"))
+`
+ await utils.sequelize.query(query)
+ }
+
+ {
+ const query = 'INSERT INTO "userNotificationSetting" ' +
+ '("newVideoFromSubscription", "newCommentOnMyVideo", "videoAbuseAsModerator", "blacklistOnMyVideo", ' +
+ '"userId", "createdAt", "updatedAt") ' +
+ '(SELECT 2, 2, 4, 4, id, NOW(), NOW() FROM "user")'
+
+ await utils.sequelize.query(query)
+ }
+}
+
+function down (options) {
+ throw new Error('Not implemented.')
+}
+
+export {
+ up,
+ down
+}
overrideTo?: string[]
}) {
logger.debug('Updating remote video "%s".', options.videoObject.uuid)
+
let videoFieldsSave: any
+ const wasPrivateVideo = options.video.privacy === VideoPrivacy.PRIVATE
+ const wasUnlistedVideo = options.video.privacy === VideoPrivacy.UNLISTED
try {
await sequelizeTypescript.transaction(async t => {
- const sequelizeOptions = {
- transaction: t
- }
+ const sequelizeOptions = { transaction: t }
videoFieldsSave = options.video.toJSON()
- const wasPrivateVideo = options.video.privacy === VideoPrivacy.PRIVATE
- const wasUnlistedVideo = options.video.privacy === VideoPrivacy.UNLISTED
-
// Check actor has the right to update the video
const videoChannel = options.video.VideoChannel
if (videoChannel.Account.id !== options.account.id) {
})
options.video.VideoCaptions = await Promise.all(videoCaptionsPromises)
}
-
- {
- // Notify our users?
- if (wasPrivateVideo || wasUnlistedVideo) {
- Notifier.Instance.notifyOnNewVideo(options.video)
- }
- }
})
+ // Notify our users?
+ if (wasPrivateVideo || wasUnlistedVideo) {
+ Notifier.Instance.notifyOnNewVideo(options.video)
+ }
+
logger.info('Remote video with uuid %s updated', options.videoObject.uuid)
} catch (err) {
if (options.video !== undefined && videoFieldsSave !== undefined) {
import * as Bull from 'bull'
-import { VideoResolution, VideoState, Job } from '../../../../shared'
+import { VideoResolution, VideoState } from '../../../../shared'
import { logger } from '../../../helpers/logger'
import { VideoModel } from '../../../models/video/video'
import { JobQueue } from '../job-queue'
import { sequelizeTypescript } from '../../../initializers'
import * as Bluebird from 'bluebird'
import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils'
-import { importVideoFile, transcodeOriginalVideofile, optimizeVideofile } from '../../video-transcoding'
+import { importVideoFile, optimizeVideofile, transcodeOriginalVideofile } from '../../video-transcoding'
import { Notifier } from '../../notifier'
export type VideoFilePayload = {
async function onVideoFileTranscoderOrImportSuccess (video: VideoModel) {
if (video === undefined) return undefined
- return sequelizeTypescript.transaction(async t => {
+ const { videoDatabase, isNewVideo } = await sequelizeTypescript.transaction(async t => {
// Maybe the video changed in database, refresh it
let videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t)
// Video does not exist anymore
// If the video was not published, we consider it is a new one for other instances
await federateVideoIfNeeded(videoDatabase, isNewVideo, t)
- if (isNewVideo) Notifier.Instance.notifyOnNewVideo(video)
- return undefined
+ return { videoDatabase, isNewVideo }
})
+
+ if (isNewVideo) Notifier.Instance.notifyOnNewVideo(videoDatabase)
}
async function onVideoFileOptimizerSuccess (videoArg: VideoModel, isNewVideo: boolean) {
// Outside the transaction (IO on disk)
const { videoFileResolution } = await videoArg.getOriginalFileResolution()
- return sequelizeTypescript.transaction(async t => {
+ const videoDatabase = await sequelizeTypescript.transaction(async t => {
// Maybe the video changed in database, refresh it
let videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid, t)
// Video does not exist anymore
}
await federateVideoIfNeeded(videoDatabase, isNewVideo, t)
- if (isNewVideo) Notifier.Instance.notifyOnNewVideo(videoDatabase)
+
+ return videoDatabase
})
+
+ if (isNewVideo) Notifier.Instance.notifyOnNewVideo(videoDatabase)
}
// ---------------------------------------------------------------------------
// Update video DB object
video.duration = duration
video.state = CONFIG.TRANSCODING.ENABLED ? VideoState.TO_TRANSCODE : VideoState.PUBLISHED
- const videoUpdated = await video.save({ transaction: t })
+ await video.save({ transaction: t })
// Now we can federate the video (reload from database, we need more attributes)
const videoForFederation = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t)
await federateVideoIfNeeded(videoForFederation, true, t)
- Notifier.Instance.notifyOnNewVideo(videoForFederation)
// Update video import object
videoImport.state = VideoImportState.SUCCESS
logger.info('Video %s imported.', video.uuid)
- videoImportUpdated.Video = videoUpdated
+ videoImportUpdated.Video = videoForFederation
return videoImportUpdated
})
+ Notifier.Instance.notifyOnNewVideo(videoImportUpdated.Video)
+
// Create transcoding jobs?
if (videoImportUpdated.Video.state === VideoState.TO_TRANSCODE) {
// Put uuid because we don't have id auto incremented for now
const videoName = 'remote video ' + videoNameId
const uuid = await uploadVideoByRemoteAccount(servers, videoNameId)
+ await waitJobs(servers)
+
await checkNewVideoFromSubscription(baseParams, videoName, uuid, 'presence')
})
}
}
const uuid = await uploadVideoByRemoteAccount(servers, videoNameId, data)
+ await waitJobs(servers)
await wait(6000)
await checkNewVideoFromSubscription(baseParams, videoName, uuid, 'presence')
const data = { privacy: VideoPrivacy.PRIVATE }
const uuid = await uploadVideoByRemoteAccount(servers, videoNameId, data)
+ await waitJobs(servers)
await checkNewVideoFromSubscription(baseParams, videoName, uuid, 'absence')
const data = { privacy: VideoPrivacy.PRIVATE }
const uuid = await uploadVideoByRemoteAccount(servers, videoNameId, data)
+ await waitJobs(servers)
await updateVideo(servers[1].url, servers[1].accessToken, uuid, { privacy: VideoPrivacy.UNLISTED })