Rename video full loading
This commit is contained in:
parent
4c8336af67
commit
4fae2b1f30
31 changed files with 48 additions and 48 deletions
|
@ -70,7 +70,7 @@ async function run () {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
const videoFull = await VideoModel.loadAndPopulateAccountAndServerAndTags(id)
|
const videoFull = await VideoModel.loadFull(id)
|
||||||
|
|
||||||
const files = videoFull.VideoFiles || []
|
const files = videoFull.VideoFiles || []
|
||||||
const hls = videoFull.getHLSPlaylist()
|
const hls = videoFull.getHLSPlaylist()
|
||||||
|
|
|
@ -43,7 +43,7 @@ async function run () {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(uuid)
|
const video = await VideoModel.loadFull(uuid)
|
||||||
if (!video) throw new Error('Video not found.')
|
if (!video) throw new Error('Video not found.')
|
||||||
|
|
||||||
const dataInput: VideoTranscodingPayload[] = []
|
const dataInput: VideoTranscodingPayload[] = []
|
||||||
|
|
|
@ -97,7 +97,7 @@ async function processVideo (videoId: number) {
|
||||||
// Everything worked, we can save the playlist now
|
// Everything worked, we can save the playlist now
|
||||||
await playlist.save()
|
await playlist.save()
|
||||||
|
|
||||||
const allVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.id)
|
const allVideo = await VideoModel.loadFull(video.id)
|
||||||
await federateVideoIfNeeded(allVideo, false)
|
await federateVideoIfNeeded(allVideo, false)
|
||||||
|
|
||||||
console.log(`Successfully moved HLS files of ${video.name}.`)
|
console.log(`Successfully moved HLS files of ${video.name}.`)
|
||||||
|
|
|
@ -114,7 +114,7 @@ async function run () {
|
||||||
|
|
||||||
const ids = await VideoModel.listLocalIds()
|
const ids = await VideoModel.listLocalIds()
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id)
|
const video = await VideoModel.loadFull(id)
|
||||||
|
|
||||||
console.log('Updating video ' + video.uuid)
|
console.log('Updating video ' + video.uuid)
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ function acceptOwnership (req: express.Request, res: express.Response) {
|
||||||
const channel = res.locals.videoChannel
|
const channel = res.locals.videoChannel
|
||||||
|
|
||||||
// We need more attributes for federation
|
// We need more attributes for federation
|
||||||
const targetVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoChangeOwnership.Video.id, t)
|
const targetVideo = await VideoModel.loadFull(videoChangeOwnership.Video.id, t)
|
||||||
|
|
||||||
const oldVideoChannel = await VideoChannelModel.loadAndPopulateAccount(targetVideo.channelId, t)
|
const oldVideoChannel = await VideoChannelModel.loadAndPopulateAccount(targetVideo.channelId, t)
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
|
||||||
try {
|
try {
|
||||||
const { videoInstanceUpdated, isNewVideo } = await sequelizeTypescript.transaction(async t => {
|
const { videoInstanceUpdated, isNewVideo } = await sequelizeTypescript.transaction(async t => {
|
||||||
// Refresh video since thumbnails to prevent concurrent updates
|
// Refresh video since thumbnails to prevent concurrent updates
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoFromReq.id, t)
|
const video = await VideoModel.loadFull(videoFromReq.id, t)
|
||||||
|
|
||||||
const sequelizeOptions = { transaction: t }
|
const sequelizeOptions = { transaction: t }
|
||||||
const oldVideoChannel = video.VideoChannel
|
const oldVideoChannel = video.VideoChannel
|
||||||
|
@ -212,5 +212,5 @@ async function updateTorrentsMetadataIfNeeded (video: MVideoFullLight, videoInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh video since files have changed
|
// Refresh video since files have changed
|
||||||
return VideoModel.loadAndPopulateAccountAndServerAndTags(video.id)
|
return VideoModel.loadFull(video.id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,7 +272,7 @@ async function createTorrentFederate (video: MVideoFullLight, videoFile: MVideoF
|
||||||
const job = await JobQueue.Instance.createJobWithPromise({ type: 'manage-video-torrent', payload })
|
const job = await JobQueue.Instance.createJobWithPromise({ type: 'manage-video-torrent', payload })
|
||||||
await job.finished()
|
await job.finished()
|
||||||
|
|
||||||
const refreshedVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.id)
|
const refreshedVideo = await VideoModel.loadFull(video.id)
|
||||||
if (!refreshedVideo) return
|
if (!refreshedVideo) return
|
||||||
|
|
||||||
// Only federate and notify after the torrent creation
|
// Only federate and notify after the torrent creation
|
||||||
|
|
|
@ -35,7 +35,7 @@ async function processDislike (activity: ActivityCreate | ActivityDislike, byAct
|
||||||
if (!onlyVideo.isOwned()) return
|
if (!onlyVideo.isOwned()) return
|
||||||
|
|
||||||
return sequelizeTypescript.transaction(async t => {
|
return sequelizeTypescript.transaction(async t => {
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(onlyVideo.id, t)
|
const video = await VideoModel.loadFull(onlyVideo.id, t)
|
||||||
|
|
||||||
const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, activity.id, t)
|
const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, activity.id, t)
|
||||||
if (existingRate && existingRate.type === 'dislike') return
|
if (existingRate && existingRate.type === 'dislike') return
|
||||||
|
|
|
@ -34,7 +34,7 @@ async function processLikeVideo (byActor: MActorSignature, activity: ActivityLik
|
||||||
if (!onlyVideo.isOwned()) return
|
if (!onlyVideo.isOwned()) return
|
||||||
|
|
||||||
return sequelizeTypescript.transaction(async t => {
|
return sequelizeTypescript.transaction(async t => {
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(onlyVideo.id, t)
|
const video = await VideoModel.loadFull(onlyVideo.id, t)
|
||||||
|
|
||||||
const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, activity.id, t)
|
const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, activity.id, t)
|
||||||
if (existingRate && existingRate.type === 'like') return
|
if (existingRate && existingRate.type === 'like') return
|
||||||
|
|
|
@ -63,7 +63,7 @@ async function processUndoLike (byActor: MActorSignature, activity: ActivityUndo
|
||||||
return sequelizeTypescript.transaction(async t => {
|
return sequelizeTypescript.transaction(async t => {
|
||||||
if (!byActor.Account) throw new Error('Unknown account ' + byActor.url)
|
if (!byActor.Account) throw new Error('Unknown account ' + byActor.url)
|
||||||
|
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(onlyVideo.id, t)
|
const video = await VideoModel.loadFull(onlyVideo.id, t)
|
||||||
const rate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byActor.Account.id, video.id, likeActivity.id, t)
|
const rate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byActor.Account.id, video.id, likeActivity.id, t)
|
||||||
if (!rate || rate.type !== 'like') throw new Error(`Unknown like by account ${byActor.Account.id} for video ${video.id}.`)
|
if (!rate || rate.type !== 'like') throw new Error(`Unknown like by account ${byActor.Account.id} for video ${video.id}.`)
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ async function processUndoDislike (byActor: MActorSignature, activity: ActivityU
|
||||||
return sequelizeTypescript.transaction(async t => {
|
return sequelizeTypescript.transaction(async t => {
|
||||||
if (!byActor.Account) throw new Error('Unknown account ' + byActor.url)
|
if (!byActor.Account) throw new Error('Unknown account ' + byActor.url)
|
||||||
|
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(onlyVideo.id, t)
|
const video = await VideoModel.loadFull(onlyVideo.id, t)
|
||||||
const rate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byActor.Account.id, video.id, dislike.id, t)
|
const rate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byActor.Account.id, video.id, dislike.id, t)
|
||||||
if (!rate || rate.type !== 'dislike') throw new Error(`Unknown dislike by account ${byActor.Account.id} for video ${video.id}.`)
|
if (!rate || rate.type !== 'dislike') throw new Error(`Unknown dislike by account ${byActor.Account.id} for video ${video.id}.`)
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ async function sendUndoCacheFile (byActor: MActor, redundancyModel: MVideoRedund
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(associatedVideo.id)
|
const video = await VideoModel.loadFull(associatedVideo.id)
|
||||||
const createActivity = buildCreateActivity(redundancyModel.url, byActor, redundancyModel.toActivityPubObject())
|
const createActivity = buildCreateActivity(redundancyModel.url, byActor, redundancyModel.toActivityPubObject())
|
||||||
|
|
||||||
return sendUndoVideoRelatedActivity({
|
return sendUndoVideoRelatedActivity({
|
||||||
|
|
|
@ -92,7 +92,7 @@ async function sendUpdateCacheFile (byActor: MActorLight, redundancyModel: MVide
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(associatedVideo.id)
|
const video = await VideoModel.loadFull(associatedVideo.id)
|
||||||
|
|
||||||
const activityBuilder = (audience: ActivityAudience) => {
|
const activityBuilder = (audience: ActivityAudience) => {
|
||||||
const redundancyObject = redundancyModel.toActivityPubObject()
|
const redundancyObject = redundancyModel.toActivityPubObject()
|
||||||
|
|
|
@ -35,7 +35,7 @@ class VideosCaptionCache extends AbstractVideoStaticFileCache <string> {
|
||||||
if (videoCaption.isOwned()) throw new Error('Cannot load remote caption of owned video.')
|
if (videoCaption.isOwned()) throw new Error('Cannot load remote caption of owned video.')
|
||||||
|
|
||||||
// Used to fetch the path
|
// Used to fetch the path
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoCaption.videoId)
|
const video = await VideoModel.loadFull(videoCaption.videoId)
|
||||||
if (!video) return undefined
|
if (!video) return undefined
|
||||||
|
|
||||||
const remoteUrl = videoCaption.getFileUrl(video)
|
const remoteUrl = videoCaption.getFileUrl(video)
|
||||||
|
|
|
@ -30,7 +30,7 @@ class VideosPreviewCache extends AbstractVideoStaticFileCache <string> {
|
||||||
|
|
||||||
// Key is the video UUID
|
// Key is the video UUID
|
||||||
protected async loadRemoteFile (key: string) {
|
protected async loadRemoteFile (key: string) {
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(key)
|
const video = await VideoModel.loadFull(key)
|
||||||
if (!video) return undefined
|
if (!video) return undefined
|
||||||
|
|
||||||
if (video.isOwned()) throw new Error('Cannot load remote preview of owned video.')
|
if (video.isOwned()) throw new Error('Cannot load remote preview of owned video.')
|
||||||
|
|
|
@ -40,7 +40,7 @@ class VideosTorrentCache extends AbstractVideoStaticFileCache <string> {
|
||||||
if (file.getVideo().isOwned()) throw new Error('Cannot load remote file of owned video.')
|
if (file.getVideo().isOwned()) throw new Error('Cannot load remote file of owned video.')
|
||||||
|
|
||||||
// Used to fetch the path
|
// Used to fetch the path
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(file.getVideo().id)
|
const video = await VideoModel.loadFull(file.getVideo().id)
|
||||||
if (!video) return undefined
|
if (!video) return undefined
|
||||||
|
|
||||||
const remoteUrl = file.getRemoteTorrentUrl(video)
|
const remoteUrl = file.getRemoteTorrentUrl(video)
|
||||||
|
|
|
@ -17,7 +17,7 @@ async function processActivityPubHttpFetcher (job: Job) {
|
||||||
const payload = job.data as ActivitypubHttpFetcherPayload
|
const payload = job.data as ActivitypubHttpFetcherPayload
|
||||||
|
|
||||||
let video: MVideoFullLight
|
let video: MVideoFullLight
|
||||||
if (payload.videoId) video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoId)
|
if (payload.videoId) video = await VideoModel.loadFull(payload.videoId)
|
||||||
|
|
||||||
const fetcherType: { [ id in FetchType ]: (items: any[]) => Promise<any> } = {
|
const fetcherType: { [ id in FetchType ]: (items: any[]) => Promise<any> } = {
|
||||||
'activity': items => processActivities(items, { outboxUrl: payload.uri, fromFetch: true }),
|
'activity': items => processActivities(items, { outboxUrl: payload.uri, fromFetch: true }),
|
||||||
|
|
|
@ -18,7 +18,7 @@ async function processVideoFileImport (job: Job) {
|
||||||
const payload = job.data as VideoFileImportPayload
|
const payload = job.data as VideoFileImportPayload
|
||||||
logger.info('Processing video file import in job %d.', job.id)
|
logger.info('Processing video file import in job %d.', job.id)
|
||||||
|
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID)
|
const video = await VideoModel.loadFull(payload.videoUUID)
|
||||||
// No video, maybe deleted?
|
// No video, maybe deleted?
|
||||||
if (!video) {
|
if (!video) {
|
||||||
logger.info('Do not process job %d, video does not exist.', job.id)
|
logger.info('Do not process job %d, video does not exist.', job.id)
|
||||||
|
|
|
@ -219,7 +219,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: MVid
|
||||||
if (previewModel) await video.addAndSaveThumbnail(previewModel, t)
|
if (previewModel) await video.addAndSaveThumbnail(previewModel, t)
|
||||||
|
|
||||||
// Now we can federate the video (reload from database, we need more attributes)
|
// Now we can federate the video (reload from database, we need more attributes)
|
||||||
const videoForFederation = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t)
|
const videoForFederation = await VideoModel.loadFull(video.uuid, t)
|
||||||
await federateVideoIfNeeded(videoForFederation, true, t)
|
await federateVideoIfNeeded(videoForFederation, true, t)
|
||||||
|
|
||||||
// Update video import object
|
// Update video import object
|
||||||
|
|
|
@ -144,7 +144,7 @@ async function replaceLiveByReplay (options: {
|
||||||
await liveSession.save()
|
await liveSession.save()
|
||||||
|
|
||||||
// Remove old HLS playlist video files
|
// Remove old HLS playlist video files
|
||||||
const videoWithFiles = await VideoModel.loadAndPopulateAccountAndServerAndTags(liveVideo.id)
|
const videoWithFiles = await VideoModel.loadFull(liveVideo.id)
|
||||||
|
|
||||||
const hlsPlaylist = videoWithFiles.getHLSPlaylist()
|
const hlsPlaylist = videoWithFiles.getHLSPlaylist()
|
||||||
await VideoFileModel.removeHLSFilesOfVideoId(hlsPlaylist.id)
|
await VideoFileModel.removeHLSFilesOfVideoId(hlsPlaylist.id)
|
||||||
|
@ -241,7 +241,7 @@ async function cleanupLiveAndFederate (options: {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fullVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.id)
|
const fullVideo = await VideoModel.loadFull(video.id)
|
||||||
return federateVideoIfNeeded(fullVideo, false, undefined)
|
return federateVideoIfNeeded(fullVideo, false, undefined)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.warn('Cannot federate live after cleanup', { videoId: video.id, err })
|
logger.warn('Cannot federate live after cleanup', { videoId: video.id, err })
|
||||||
|
|
|
@ -44,7 +44,7 @@ async function processVideoStudioEdition (job: Job) {
|
||||||
|
|
||||||
logger.info('Process video studio edition of %s in job %d.', payload.videoUUID, job.id, lTags)
|
logger.info('Process video studio edition of %s in job %d.', payload.videoUUID, job.id, lTags)
|
||||||
|
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID)
|
const video = await VideoModel.loadFull(payload.videoUUID)
|
||||||
|
|
||||||
// No video, maybe deleted?
|
// No video, maybe deleted?
|
||||||
if (!video) {
|
if (!video) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ async function processVideoTranscoding (job: Job) {
|
||||||
const payload = job.data as VideoTranscodingPayload
|
const payload = job.data as VideoTranscodingPayload
|
||||||
logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID))
|
logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID))
|
||||||
|
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID)
|
const video = await VideoModel.loadFull(payload.videoUUID)
|
||||||
// No video, maybe deleted?
|
// No video, maybe deleted?
|
||||||
if (!video) {
|
if (!video) {
|
||||||
logger.info('Do not process job %d, video does not exist.', job.id, lTags(payload.videoUUID))
|
logger.info('Do not process job %d, video does not exist.', job.id, lTags(payload.videoUUID))
|
||||||
|
@ -180,7 +180,7 @@ async function onVideoFirstWebTorrentTranscoding (
|
||||||
const { resolution, isPortraitMode, audioStream } = await videoArg.probeMaxQualityFile()
|
const { resolution, isPortraitMode, audioStream } = await videoArg.probeMaxQualityFile()
|
||||||
|
|
||||||
// Maybe the video changed in database, refresh it
|
// Maybe the video changed in database, refresh it
|
||||||
const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid)
|
const videoDatabase = await VideoModel.loadFull(videoArg.uuid)
|
||||||
// Video does not exist anymore
|
// Video does not exist anymore
|
||||||
if (!videoDatabase) return undefined
|
if (!videoDatabase) return undefined
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,7 @@ class LiveManager {
|
||||||
const videoId = live.videoId
|
const videoId = live.videoId
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId)
|
const video = await VideoModel.loadFull(videoId)
|
||||||
|
|
||||||
logger.info('Will publish and federate live %s.', video.url, localLTags)
|
logger.info('Will publish and federate live %s.', video.url, localLTags)
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ class LiveManager {
|
||||||
const { videoId, liveSession: liveSessionArg, cleanupNow = false } = options
|
const { videoId, liveSession: liveSessionArg, cleanupNow = false } = options
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fullVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId)
|
const fullVideo = await VideoModel.loadFull(videoId)
|
||||||
if (!fullVideo) return
|
if (!fullVideo) return
|
||||||
|
|
||||||
const live = await VideoLiveModel.loadByVideoId(fullVideo.id)
|
const live = await VideoLiveModel.loadByVideoId(fullVideo.id)
|
||||||
|
|
|
@ -35,7 +35,7 @@ function loadVideo (
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId)
|
if (fetchType === 'all') return VideoModel.loadFull(id, undefined, userId)
|
||||||
|
|
||||||
if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id)
|
if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id)
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ function buildVideosHelpers () {
|
||||||
|
|
||||||
removeVideo: (id: number) => {
|
removeVideo: (id: number) => {
|
||||||
return sequelizeTypescript.transaction(async t => {
|
return sequelizeTypescript.transaction(async t => {
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id, t)
|
const video = await VideoModel.loadFull(id, t)
|
||||||
|
|
||||||
await video.destroy({ transaction: t })
|
await video.destroy({ transaction: t })
|
||||||
})
|
})
|
||||||
|
@ -94,7 +94,7 @@ function buildVideosHelpers () {
|
||||||
},
|
},
|
||||||
|
|
||||||
getFiles: async (id: number | string) => {
|
getFiles: async (id: number | string) => {
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id)
|
const video = await VideoModel.loadFull(id)
|
||||||
if (!video) return undefined
|
if (!video) return undefined
|
||||||
|
|
||||||
const webtorrentVideoFiles = (video.VideoFiles || []).map(f => ({
|
const webtorrentVideoFiles = (video.VideoFiles || []).map(f => ({
|
||||||
|
@ -178,14 +178,14 @@ function buildModerationHelpers () {
|
||||||
},
|
},
|
||||||
|
|
||||||
blacklistVideo: async (options: { videoIdOrUUID: number | string, createOptions: VideoBlacklistCreate }) => {
|
blacklistVideo: async (options: { videoIdOrUUID: number | string, createOptions: VideoBlacklistCreate }) => {
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.videoIdOrUUID)
|
const video = await VideoModel.loadFull(options.videoIdOrUUID)
|
||||||
if (!video) return
|
if (!video) return
|
||||||
|
|
||||||
await blacklistVideo(video, options.createOptions)
|
await blacklistVideo(video, options.createOptions)
|
||||||
},
|
},
|
||||||
|
|
||||||
unblacklistVideo: async (options: { videoIdOrUUID: number | string }) => {
|
unblacklistVideo: async (options: { videoIdOrUUID: number | string }) => {
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.videoIdOrUUID)
|
const video = await VideoModel.loadFull(options.videoIdOrUUID)
|
||||||
if (!video) return
|
if (!video) return
|
||||||
|
|
||||||
const videoBlacklist = await VideoBlacklistModel.loadByVideoId(video.id)
|
const videoBlacklist = await VideoBlacklistModel.loadByVideoId(video.id)
|
||||||
|
|
|
@ -30,7 +30,7 @@ export class UpdateVideosScheduler extends AbstractScheduler {
|
||||||
|
|
||||||
for (const schedule of schedules) {
|
for (const schedule of schedules) {
|
||||||
await sequelizeTypescript.transaction(async t => {
|
await sequelizeTypescript.transaction(async t => {
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(schedule.videoId, t)
|
const video = await VideoModel.loadFull(schedule.videoId, t)
|
||||||
|
|
||||||
logger.info('Executing scheduled video update on %s.', video.uuid)
|
logger.info('Executing scheduled video update on %s.', video.uuid)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ export class VideoViewsBufferScheduler extends AbstractScheduler {
|
||||||
const views = await Redis.Instance.getLocalVideoViews(videoId)
|
const views = await Redis.Instance.getLocalVideoViews(videoId)
|
||||||
await Redis.Instance.deleteLocalVideoViews(videoId)
|
await Redis.Instance.deleteLocalVideoViews(videoId)
|
||||||
|
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId)
|
const video = await VideoModel.loadFull(videoId)
|
||||||
if (!video) {
|
if (!video) {
|
||||||
logger.debug('Video %d does not exist anymore, skipping videos view addition.', videoId, lTags())
|
logger.debug('Video %d does not exist anymore, skipping videos view addition.', videoId, lTags())
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -36,7 +36,7 @@ async function federateAllVideosOfChannel (videoChannel: MChannelId) {
|
||||||
const videoIds = await VideoModel.getAllIdsFromChannel(videoChannel)
|
const videoIds = await VideoModel.getAllIdsFromChannel(videoChannel)
|
||||||
|
|
||||||
for (const videoId of videoIds) {
|
for (const videoId of videoIds) {
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId)
|
const video = await VideoModel.loadFull(videoId)
|
||||||
|
|
||||||
await federateVideoIfNeeded(video, false)
|
await federateVideoIfNeeded(video, false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ function moveToNextState (options: {
|
||||||
|
|
||||||
return sequelizeTypescript.transaction(async t => {
|
return sequelizeTypescript.transaction(async t => {
|
||||||
// Maybe the video changed in database, refresh it
|
// Maybe the video changed in database, refresh it
|
||||||
const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t)
|
const videoDatabase = await VideoModel.loadFull(video.uuid, t)
|
||||||
// Video does not exist anymore
|
// Video does not exist anymore
|
||||||
if (!videoDatabase) return undefined
|
if (!videoDatabase) return undefined
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ async function checkCanSeeAuthVideo (req: Request, res: Response, video: MVideoI
|
||||||
|
|
||||||
const videoWithRights = (video as MVideoWithRights).VideoChannel?.Account?.userId
|
const videoWithRights = (video as MVideoWithRights).VideoChannel?.Account?.userId
|
||||||
? video as MVideoWithRights
|
? video as MVideoWithRights
|
||||||
: await VideoModel.loadAndPopulateAccountAndServerAndTags(video.id)
|
: await VideoModel.loadFull(video.id)
|
||||||
|
|
||||||
const privacy = videoWithRights.privacy
|
const privacy = videoWithRights.privacy
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import { VideoTableAttributes } from './shared/video-table-attributes'
|
||||||
|
|
||||||
export type GetType =
|
export type GetType =
|
||||||
'api' |
|
'api' |
|
||||||
'full-light' |
|
'full' |
|
||||||
'account-blacklist-files' |
|
'account-blacklist-files' |
|
||||||
'all-files' |
|
'all-files' |
|
||||||
'thumbnails' |
|
'thumbnails' |
|
||||||
|
@ -40,7 +40,7 @@ export class VideoModelGetQueryBuilder {
|
||||||
|
|
||||||
private readonly videoModelBuilder: VideoModelBuilder
|
private readonly videoModelBuilder: VideoModelBuilder
|
||||||
|
|
||||||
private static readonly videoFilesInclude = new Set<GetType>([ 'api', 'full-light', 'account-blacklist-files', 'all-files' ])
|
private static readonly videoFilesInclude = new Set<GetType>([ 'api', 'full', 'account-blacklist-files', 'all-files' ])
|
||||||
|
|
||||||
constructor (protected readonly sequelize: Sequelize) {
|
constructor (protected readonly sequelize: Sequelize) {
|
||||||
this.videoQueryBuilder = new VideosModelGetQuerySubBuilder(sequelize)
|
this.videoQueryBuilder = new VideosModelGetQuerySubBuilder(sequelize)
|
||||||
|
@ -96,16 +96,16 @@ export class VideosModelGetQuerySubBuilder extends AbstractVideoQueryBuilder {
|
||||||
protected streamingPlaylistFilesQuery: string
|
protected streamingPlaylistFilesQuery: string
|
||||||
|
|
||||||
private static readonly trackersInclude = new Set<GetType>([ 'api' ])
|
private static readonly trackersInclude = new Set<GetType>([ 'api' ])
|
||||||
private static readonly liveInclude = new Set<GetType>([ 'api', 'full-light' ])
|
private static readonly liveInclude = new Set<GetType>([ 'api', 'full' ])
|
||||||
private static readonly scheduleUpdateInclude = new Set<GetType>([ 'api', 'full-light' ])
|
private static readonly scheduleUpdateInclude = new Set<GetType>([ 'api', 'full' ])
|
||||||
private static readonly tagsInclude = new Set<GetType>([ 'api', 'full-light' ])
|
private static readonly tagsInclude = new Set<GetType>([ 'api', 'full' ])
|
||||||
private static readonly userHistoryInclude = new Set<GetType>([ 'api', 'full-light' ])
|
private static readonly userHistoryInclude = new Set<GetType>([ 'api', 'full' ])
|
||||||
private static readonly accountInclude = new Set<GetType>([ 'api', 'full-light', 'account-blacklist-files' ])
|
private static readonly accountInclude = new Set<GetType>([ 'api', 'full', 'account-blacklist-files' ])
|
||||||
private static readonly ownerUserInclude = new Set<GetType>([ 'blacklist-rights' ])
|
private static readonly ownerUserInclude = new Set<GetType>([ 'blacklist-rights' ])
|
||||||
|
|
||||||
private static readonly blacklistedInclude = new Set<GetType>([
|
private static readonly blacklistedInclude = new Set<GetType>([
|
||||||
'api',
|
'api',
|
||||||
'full-light',
|
'full',
|
||||||
'account-blacklist-files',
|
'account-blacklist-files',
|
||||||
'thumbnails-blacklist',
|
'thumbnails-blacklist',
|
||||||
'blacklist-rights'
|
'blacklist-rights'
|
||||||
|
@ -113,7 +113,7 @@ export class VideosModelGetQuerySubBuilder extends AbstractVideoQueryBuilder {
|
||||||
|
|
||||||
private static readonly thumbnailsInclude = new Set<GetType>([
|
private static readonly thumbnailsInclude = new Set<GetType>([
|
||||||
'api',
|
'api',
|
||||||
'full-light',
|
'full',
|
||||||
'account-blacklist-files',
|
'account-blacklist-files',
|
||||||
'all-files',
|
'all-files',
|
||||||
'thumbnails',
|
'thumbnails',
|
||||||
|
|
|
@ -1352,10 +1352,10 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
||||||
return queryBuilder.queryVideo({ url, transaction, type: 'account-blacklist-files' })
|
return queryBuilder.queryVideo({ url, transaction, type: 'account-blacklist-files' })
|
||||||
}
|
}
|
||||||
|
|
||||||
static loadAndPopulateAccountAndServerAndTags (id: number | string, t?: Transaction, userId?: number): Promise<MVideoFullLight> {
|
static loadFull (id: number | string, t?: Transaction, userId?: number): Promise<MVideoFullLight> {
|
||||||
const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)
|
const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)
|
||||||
|
|
||||||
return queryBuilder.queryVideo({ id, transaction: t, type: 'full-light', userId })
|
return queryBuilder.queryVideo({ id, transaction: t, type: 'full', userId })
|
||||||
}
|
}
|
||||||
|
|
||||||
static loadForGetAPI (parameters: {
|
static loadForGetAPI (parameters: {
|
||||||
|
|
Loading…
Reference in a new issue