From 4fae2b1f300c1f027629569817262f60873a663a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 28 Jun 2022 14:57:51 +0200 Subject: [PATCH] Rename video full loading --- scripts/create-move-video-storage-job.ts | 2 +- scripts/create-transcoding-job.ts | 2 +- scripts/migrations/peertube-4.0.ts | 2 +- scripts/update-host.ts | 2 +- server/controllers/api/videos/ownership.ts | 2 +- server/controllers/api/videos/update.ts | 4 ++-- server/controllers/api/videos/upload.ts | 2 +- .../lib/activitypub/process/process-dislike.ts | 2 +- server/lib/activitypub/process/process-like.ts | 2 +- server/lib/activitypub/process/process-undo.ts | 4 ++-- server/lib/activitypub/send/send-undo.ts | 2 +- server/lib/activitypub/send/send-update.ts | 2 +- server/lib/files-cache/videos-caption-cache.ts | 2 +- server/lib/files-cache/videos-preview-cache.ts | 2 +- server/lib/files-cache/videos-torrent-cache.ts | 2 +- .../handlers/activitypub-http-fetcher.ts | 2 +- .../job-queue/handlers/video-file-import.ts | 2 +- server/lib/job-queue/handlers/video-import.ts | 2 +- .../job-queue/handlers/video-live-ending.ts | 4 ++-- .../job-queue/handlers/video-studio-edition.ts | 2 +- .../job-queue/handlers/video-transcoding.ts | 4 ++-- server/lib/live/live-manager.ts | 4 ++-- server/lib/model-loaders/video.ts | 2 +- server/lib/plugins/plugin-helpers-builder.ts | 8 ++++---- .../lib/schedulers/update-videos-scheduler.ts | 2 +- .../schedulers/video-views-buffer-scheduler.ts | 2 +- server/lib/video-channel.ts | 2 +- server/lib/video-state.ts | 2 +- server/middlewares/validators/shared/videos.ts | 2 +- .../sql/video/video-model-get-query-builder.ts | 18 +++++++++--------- server/models/video/video.ts | 4 ++-- 31 files changed, 48 insertions(+), 48 deletions(-) diff --git a/scripts/create-move-video-storage-job.ts b/scripts/create-move-video-storage-job.ts index 18629aa27..0f0d4ee35 100644 --- a/scripts/create-move-video-storage-job.ts +++ b/scripts/create-move-video-storage-job.ts @@ -70,7 +70,7 @@ async function run () { } for (const id of ids) { - const videoFull = await VideoModel.loadAndPopulateAccountAndServerAndTags(id) + const videoFull = await VideoModel.loadFull(id) const files = videoFull.VideoFiles || [] const hls = videoFull.getHLSPlaylist() diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts index 59fc84ad5..8f4d64290 100755 --- a/scripts/create-transcoding-job.ts +++ b/scripts/create-transcoding-job.ts @@ -43,7 +43,7 @@ async function run () { return } - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(uuid) + const video = await VideoModel.loadFull(uuid) if (!video) throw new Error('Video not found.') const dataInput: VideoTranscodingPayload[] = [] diff --git a/scripts/migrations/peertube-4.0.ts b/scripts/migrations/peertube-4.0.ts index 64cf45474..9e5ca60d4 100644 --- a/scripts/migrations/peertube-4.0.ts +++ b/scripts/migrations/peertube-4.0.ts @@ -97,7 +97,7 @@ async function processVideo (videoId: number) { // Everything worked, we can save the playlist now await playlist.save() - const allVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.id) + const allVideo = await VideoModel.loadFull(video.id) await federateVideoIfNeeded(allVideo, false) console.log(`Successfully moved HLS files of ${video.name}.`) diff --git a/scripts/update-host.ts b/scripts/update-host.ts index bb54290a4..1d17ce152 100755 --- a/scripts/update-host.ts +++ b/scripts/update-host.ts @@ -114,7 +114,7 @@ async function run () { const ids = await VideoModel.listLocalIds() for (const id of ids) { - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id) + const video = await VideoModel.loadFull(id) console.log('Updating video ' + video.uuid) diff --git a/server/controllers/api/videos/ownership.ts b/server/controllers/api/videos/ownership.ts index 043861ac3..88355b289 100644 --- a/server/controllers/api/videos/ownership.ts +++ b/server/controllers/api/videos/ownership.ts @@ -105,7 +105,7 @@ function acceptOwnership (req: express.Request, res: express.Response) { const channel = res.locals.videoChannel // 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) diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts index 2cf8a5883..65a7321fd 100644 --- a/server/controllers/api/videos/update.ts +++ b/server/controllers/api/videos/update.ts @@ -62,7 +62,7 @@ async function updateVideo (req: express.Request, res: express.Response) { try { const { videoInstanceUpdated, isNewVideo } = await sequelizeTypescript.transaction(async t => { // 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 oldVideoChannel = video.VideoChannel @@ -212,5 +212,5 @@ async function updateTorrentsMetadataIfNeeded (video: MVideoFullLight, videoInfo } // Refresh video since files have changed - return VideoModel.loadAndPopulateAccountAndServerAndTags(video.id) + return VideoModel.loadFull(video.id) } diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts index c5890691e..3ce66c9ca 100644 --- a/server/controllers/api/videos/upload.ts +++ b/server/controllers/api/videos/upload.ts @@ -272,7 +272,7 @@ async function createTorrentFederate (video: MVideoFullLight, videoFile: MVideoF const job = await JobQueue.Instance.createJobWithPromise({ type: 'manage-video-torrent', payload }) await job.finished() - const refreshedVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.id) + const refreshedVideo = await VideoModel.loadFull(video.id) if (!refreshedVideo) return // Only federate and notify after the torrent creation diff --git a/server/lib/activitypub/process/process-dislike.ts b/server/lib/activitypub/process/process-dislike.ts index 97a994e94..44e349b22 100644 --- a/server/lib/activitypub/process/process-dislike.ts +++ b/server/lib/activitypub/process/process-dislike.ts @@ -35,7 +35,7 @@ async function processDislike (activity: ActivityCreate | ActivityDislike, byAct if (!onlyVideo.isOwned()) return 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) if (existingRate && existingRate.type === 'dislike') return diff --git a/server/lib/activitypub/process/process-like.ts b/server/lib/activitypub/process/process-like.ts index 1aee756d8..580a05bcd 100644 --- a/server/lib/activitypub/process/process-like.ts +++ b/server/lib/activitypub/process/process-like.ts @@ -34,7 +34,7 @@ async function processLikeVideo (byActor: MActorSignature, activity: ActivityLik if (!onlyVideo.isOwned()) return 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) if (existingRate && existingRate.type === 'like') return diff --git a/server/lib/activitypub/process/process-undo.ts b/server/lib/activitypub/process/process-undo.ts index 257eb6c2b..778a38e05 100644 --- a/server/lib/activitypub/process/process-undo.ts +++ b/server/lib/activitypub/process/process-undo.ts @@ -63,7 +63,7 @@ async function processUndoLike (byActor: MActorSignature, activity: ActivityUndo return sequelizeTypescript.transaction(async t => { 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) 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 => { 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) if (!rate || rate.type !== 'dislike') throw new Error(`Unknown dislike by account ${byActor.Account.id} for video ${video.id}.`) diff --git a/server/lib/activitypub/send/send-undo.ts b/server/lib/activitypub/send/send-undo.ts index 442178c42..b8eb47ff6 100644 --- a/server/lib/activitypub/send/send-undo.ts +++ b/server/lib/activitypub/send/send-undo.ts @@ -83,7 +83,7 @@ async function sendUndoCacheFile (byActor: MActor, redundancyModel: MVideoRedund return } - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(associatedVideo.id) + const video = await VideoModel.loadFull(associatedVideo.id) const createActivity = buildCreateActivity(redundancyModel.url, byActor, redundancyModel.toActivityPubObject()) return sendUndoVideoRelatedActivity({ diff --git a/server/lib/activitypub/send/send-update.ts b/server/lib/activitypub/send/send-update.ts index 3577ece02..24983dd19 100644 --- a/server/lib/activitypub/send/send-update.ts +++ b/server/lib/activitypub/send/send-update.ts @@ -92,7 +92,7 @@ async function sendUpdateCacheFile (byActor: MActorLight, redundancyModel: MVide return } - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(associatedVideo.id) + const video = await VideoModel.loadFull(associatedVideo.id) const activityBuilder = (audience: ActivityAudience) => { const redundancyObject = redundancyModel.toActivityPubObject() diff --git a/server/lib/files-cache/videos-caption-cache.ts b/server/lib/files-cache/videos-caption-cache.ts index 58e2260b6..2927c37eb 100644 --- a/server/lib/files-cache/videos-caption-cache.ts +++ b/server/lib/files-cache/videos-caption-cache.ts @@ -35,7 +35,7 @@ class VideosCaptionCache extends AbstractVideoStaticFileCache { if (videoCaption.isOwned()) throw new Error('Cannot load remote caption of owned video.') // Used to fetch the path - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoCaption.videoId) + const video = await VideoModel.loadFull(videoCaption.videoId) if (!video) return undefined const remoteUrl = videoCaption.getFileUrl(video) diff --git a/server/lib/files-cache/videos-preview-cache.ts b/server/lib/files-cache/videos-preview-cache.ts index dd3a84aca..b7a8d6105 100644 --- a/server/lib/files-cache/videos-preview-cache.ts +++ b/server/lib/files-cache/videos-preview-cache.ts @@ -30,7 +30,7 @@ class VideosPreviewCache extends AbstractVideoStaticFileCache { // Key is the video UUID protected async loadRemoteFile (key: string) { - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(key) + const video = await VideoModel.loadFull(key) if (!video) return undefined if (video.isOwned()) throw new Error('Cannot load remote preview of owned video.') diff --git a/server/lib/files-cache/videos-torrent-cache.ts b/server/lib/files-cache/videos-torrent-cache.ts index 23217f140..c8188b79f 100644 --- a/server/lib/files-cache/videos-torrent-cache.ts +++ b/server/lib/files-cache/videos-torrent-cache.ts @@ -40,7 +40,7 @@ class VideosTorrentCache extends AbstractVideoStaticFileCache { if (file.getVideo().isOwned()) throw new Error('Cannot load remote file of owned video.') // 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 const remoteUrl = file.getRemoteTorrentUrl(video) diff --git a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts index 128e14f94..de533de6c 100644 --- a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts +++ b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts @@ -17,7 +17,7 @@ async function processActivityPubHttpFetcher (job: Job) { const payload = job.data as ActivitypubHttpFetcherPayload 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 } = { 'activity': items => processActivities(items, { outboxUrl: payload.uri, fromFetch: true }), diff --git a/server/lib/job-queue/handlers/video-file-import.ts b/server/lib/job-queue/handlers/video-file-import.ts index 110176d81..1c600e2a7 100644 --- a/server/lib/job-queue/handlers/video-file-import.ts +++ b/server/lib/job-queue/handlers/video-file-import.ts @@ -18,7 +18,7 @@ async function processVideoFileImport (job: Job) { const payload = job.data as VideoFileImportPayload 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? if (!video) { logger.info('Do not process job %d, video does not exist.', job.id) diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index d59a1b12f..40804e82e 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts @@ -219,7 +219,7 @@ async function processFile (downloader: () => Promise, videoImport: MVid if (previewModel) await video.addAndSaveThumbnail(previewModel, t) // 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) // Update video import object diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts index b2c42664a..0e1bfb240 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/lib/job-queue/handlers/video-live-ending.ts @@ -144,7 +144,7 @@ async function replaceLiveByReplay (options: { await liveSession.save() // Remove old HLS playlist video files - const videoWithFiles = await VideoModel.loadAndPopulateAccountAndServerAndTags(liveVideo.id) + const videoWithFiles = await VideoModel.loadFull(liveVideo.id) const hlsPlaylist = videoWithFiles.getHLSPlaylist() await VideoFileModel.removeHLSFilesOfVideoId(hlsPlaylist.id) @@ -241,7 +241,7 @@ async function cleanupLiveAndFederate (options: { } try { - const fullVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.id) + const fullVideo = await VideoModel.loadFull(video.id) return federateVideoIfNeeded(fullVideo, false, undefined) } catch (err) { logger.warn('Cannot federate live after cleanup', { videoId: video.id, err }) diff --git a/server/lib/job-queue/handlers/video-studio-edition.ts b/server/lib/job-queue/handlers/video-studio-edition.ts index cf3064a7a..434d0ffe8 100644 --- a/server/lib/job-queue/handlers/video-studio-edition.ts +++ b/server/lib/job-queue/handlers/video-studio-edition.ts @@ -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) - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID) + const video = await VideoModel.loadFull(payload.videoUUID) // No video, maybe deleted? if (!video) { diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index 95ee6b384..5afca65ca 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts @@ -42,7 +42,7 @@ async function processVideoTranscoding (job: Job) { const payload = job.data as VideoTranscodingPayload 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? if (!video) { 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() // 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 if (!videoDatabase) return undefined diff --git a/server/lib/live/live-manager.ts b/server/lib/live/live-manager.ts index d499b4b1a..74f203091 100644 --- a/server/lib/live/live-manager.ts +++ b/server/lib/live/live-manager.ts @@ -351,7 +351,7 @@ class LiveManager { const videoId = live.videoId try { - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId) + const video = await VideoModel.loadFull(videoId) logger.info('Will publish and federate live %s.', video.url, localLTags) @@ -390,7 +390,7 @@ class LiveManager { const { videoId, liveSession: liveSessionArg, cleanupNow = false } = options try { - const fullVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId) + const fullVideo = await VideoModel.loadFull(videoId) if (!fullVideo) return const live = await VideoLiveModel.loadByVideoId(fullVideo.id) diff --git a/server/lib/model-loaders/video.ts b/server/lib/model-loaders/video.ts index 0a3c15ad8..cef6a367c 100644 --- a/server/lib/model-loaders/video.ts +++ b/server/lib/model-loaders/video.ts @@ -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) diff --git a/server/lib/plugins/plugin-helpers-builder.ts b/server/lib/plugins/plugin-helpers-builder.ts index 897271c0b..b76c0a8a4 100644 --- a/server/lib/plugins/plugin-helpers-builder.ts +++ b/server/lib/plugins/plugin-helpers-builder.ts @@ -83,7 +83,7 @@ function buildVideosHelpers () { removeVideo: (id: number) => { return sequelizeTypescript.transaction(async t => { - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id, t) + const video = await VideoModel.loadFull(id, t) await video.destroy({ transaction: t }) }) @@ -94,7 +94,7 @@ function buildVideosHelpers () { }, getFiles: async (id: number | string) => { - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id) + const video = await VideoModel.loadFull(id) if (!video) return undefined const webtorrentVideoFiles = (video.VideoFiles || []).map(f => ({ @@ -178,14 +178,14 @@ function buildModerationHelpers () { }, 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 await blacklistVideo(video, options.createOptions) }, unblacklistVideo: async (options: { videoIdOrUUID: number | string }) => { - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.videoIdOrUUID) + const video = await VideoModel.loadFull(options.videoIdOrUUID) if (!video) return const videoBlacklist = await VideoBlacklistModel.loadByVideoId(video.id) diff --git a/server/lib/schedulers/update-videos-scheduler.ts b/server/lib/schedulers/update-videos-scheduler.ts index c652682dd..5bfbc3cd2 100644 --- a/server/lib/schedulers/update-videos-scheduler.ts +++ b/server/lib/schedulers/update-videos-scheduler.ts @@ -30,7 +30,7 @@ export class UpdateVideosScheduler extends AbstractScheduler { for (const schedule of schedules) { 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) diff --git a/server/lib/schedulers/video-views-buffer-scheduler.ts b/server/lib/schedulers/video-views-buffer-scheduler.ts index 937764155..244a88b14 100644 --- a/server/lib/schedulers/video-views-buffer-scheduler.ts +++ b/server/lib/schedulers/video-views-buffer-scheduler.ts @@ -26,7 +26,7 @@ export class VideoViewsBufferScheduler extends AbstractScheduler { const views = await Redis.Instance.getLocalVideoViews(videoId) await Redis.Instance.deleteLocalVideoViews(videoId) - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId) + const video = await VideoModel.loadFull(videoId) if (!video) { logger.debug('Video %d does not exist anymore, skipping videos view addition.', videoId, lTags()) continue diff --git a/server/lib/video-channel.ts b/server/lib/video-channel.ts index 2fd63a8c4..8322c9ad2 100644 --- a/server/lib/video-channel.ts +++ b/server/lib/video-channel.ts @@ -36,7 +36,7 @@ async function federateAllVideosOfChannel (videoChannel: MChannelId) { const videoIds = await VideoModel.getAllIdsFromChannel(videoChannel) for (const videoId of videoIds) { - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId) + const video = await VideoModel.loadFull(videoId) await federateVideoIfNeeded(video, false) } diff --git a/server/lib/video-state.ts b/server/lib/video-state.ts index ae2725d65..b4e3831e5 100644 --- a/server/lib/video-state.ts +++ b/server/lib/video-state.ts @@ -43,7 +43,7 @@ function moveToNextState (options: { return sequelizeTypescript.transaction(async t => { // 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 if (!videoDatabase) return undefined diff --git a/server/middlewares/validators/shared/videos.ts b/server/middlewares/validators/shared/videos.ts index 2c2ae3811..e3a98c58f 100644 --- a/server/middlewares/validators/shared/videos.ts +++ b/server/middlewares/validators/shared/videos.ts @@ -144,7 +144,7 @@ async function checkCanSeeAuthVideo (req: Request, res: Response, video: MVideoI const videoWithRights = (video as MVideoWithRights).VideoChannel?.Account?.userId ? video as MVideoWithRights - : await VideoModel.loadAndPopulateAccountAndServerAndTags(video.id) + : await VideoModel.loadFull(video.id) const privacy = videoWithRights.privacy diff --git a/server/models/video/sql/video/video-model-get-query-builder.ts b/server/models/video/sql/video/video-model-get-query-builder.ts index 32e5c4ff7..29e59c8be 100644 --- a/server/models/video/sql/video/video-model-get-query-builder.ts +++ b/server/models/video/sql/video/video-model-get-query-builder.ts @@ -13,7 +13,7 @@ import { VideoTableAttributes } from './shared/video-table-attributes' export type GetType = 'api' | - 'full-light' | + 'full' | 'account-blacklist-files' | 'all-files' | 'thumbnails' | @@ -40,7 +40,7 @@ export class VideoModelGetQueryBuilder { private readonly videoModelBuilder: VideoModelBuilder - private static readonly videoFilesInclude = new Set([ 'api', 'full-light', 'account-blacklist-files', 'all-files' ]) + private static readonly videoFilesInclude = new Set([ 'api', 'full', 'account-blacklist-files', 'all-files' ]) constructor (protected readonly sequelize: Sequelize) { this.videoQueryBuilder = new VideosModelGetQuerySubBuilder(sequelize) @@ -96,16 +96,16 @@ export class VideosModelGetQuerySubBuilder extends AbstractVideoQueryBuilder { protected streamingPlaylistFilesQuery: string private static readonly trackersInclude = new Set([ 'api' ]) - private static readonly liveInclude = new Set([ 'api', 'full-light' ]) - private static readonly scheduleUpdateInclude = new Set([ 'api', 'full-light' ]) - private static readonly tagsInclude = new Set([ 'api', 'full-light' ]) - private static readonly userHistoryInclude = new Set([ 'api', 'full-light' ]) - private static readonly accountInclude = new Set([ 'api', 'full-light', 'account-blacklist-files' ]) + private static readonly liveInclude = new Set([ 'api', 'full' ]) + private static readonly scheduleUpdateInclude = new Set([ 'api', 'full' ]) + private static readonly tagsInclude = new Set([ 'api', 'full' ]) + private static readonly userHistoryInclude = new Set([ 'api', 'full' ]) + private static readonly accountInclude = new Set([ 'api', 'full', 'account-blacklist-files' ]) private static readonly ownerUserInclude = new Set([ 'blacklist-rights' ]) private static readonly blacklistedInclude = new Set([ 'api', - 'full-light', + 'full', 'account-blacklist-files', 'thumbnails-blacklist', 'blacklist-rights' @@ -113,7 +113,7 @@ export class VideosModelGetQuerySubBuilder extends AbstractVideoQueryBuilder { private static readonly thumbnailsInclude = new Set([ 'api', - 'full-light', + 'full', 'account-blacklist-files', 'all-files', 'thumbnails', diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 08adbced6..e5f8b5fa2 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -1352,10 +1352,10 @@ export class VideoModel extends Model>> { return queryBuilder.queryVideo({ url, transaction, type: 'account-blacklist-files' }) } - static loadAndPopulateAccountAndServerAndTags (id: number | string, t?: Transaction, userId?: number): Promise { + static loadFull (id: number | string, t?: Transaction, userId?: number): Promise { 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: {