+import { VideoLiveModel } from '@server/models/video/video-live'
import * as Bluebird from 'bluebird'
import { maxBy, minBy } from 'lodash'
import * as magnetUtil from 'magnet-uri'
// Check this is not a blacklisted video, or unfederated blacklisted video
(video.isBlacklisted() === false || (isNewVideo === false && video.VideoBlacklist.unfederated === false)) &&
// Check the video is public/unlisted and published
- video.hasPrivacyForFederation() && video.state === VideoState.PUBLISHED
+ video.hasPrivacyForFederation() && video.hasStateForFederation()
) {
// Fetch more attributes that we will need to serialize in AP object
if (isArray(video.VideoCaptions) === false) {
}) {
const { video, videoObject, account, channel, overrideTo } = options
- logger.debug('Updating remote video "%s".', options.videoObject.uuid, { account, channel })
+ logger.debug('Updating remote video "%s".', options.videoObject.uuid, { videoObject: options.videoObject, account, channel })
let videoFieldsSave: any
const wasPrivateVideo = video.privacy === VideoPrivacy.PRIVATE
await Promise.all(videoCaptionsPromises)
}
+ {
+ // Create or update existing live
+ if (video.isLive) {
+ const [ videoLive ] = await VideoLiveModel.upsert({
+ saveReplay: videoObject.liveSaveReplay,
+ videoId: video.id
+ }, { transaction: t, returning: true })
+
+ videoUpdated.VideoLive = videoLive
+ } else { // Delete existing live if it exists
+ await VideoLiveModel.destroy({
+ where: {
+ videoId: video.id
+ },
+ transaction: t
+ })
+
+ videoUpdated.VideoLive = null
+ }
+ }
+
return videoUpdated
})
})
if (wasPrivateVideo || wasUnlistedVideo) Notifier.Instance.notifyOnNewVideoIfNeeded(videoUpdated) // Notify our users?
- if (videoUpdated.isLive) PeerTubeSocket.Instance.sendVideoLiveNewState(video)
+ if (videoUpdated.isLive) PeerTubeSocket.Instance.sendVideoLiveNewState(videoUpdated)
logger.info('Remote video with uuid %s updated', videoObject.uuid)
return url && url.type === 'Hashtag'
}
+
+
async function createVideo (videoObject: VideoObject, channel: MChannelAccountLight, waitThumbnail = false) {
logger.debug('Adding remote video %s.', videoObject.id)
videoCreated.VideoFiles = videoFiles
+ if (videoCreated.isLive) {
+ const videoLive = new VideoLiveModel({
+ streamKey: null,
+ saveReplay: videoObject.liveSaveReplay,
+ videoId: videoCreated.id
+ })
+
+ videoCreated.VideoLive = await videoLive.save({ transaction: t })
+ }
+
const autoBlacklisted = await autoBlacklistVideoIfNeeded({
video: videoCreated,
user: undefined,