diff options
author | Chocobozzz <me@florianbigard.com> | 2022-06-28 14:57:51 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-06-28 15:06:15 +0200 |
commit | 4fae2b1f300c1f027629569817262f60873a663a (patch) | |
tree | fabffae6d39aa13b19985f8c92730db2a721dceb | |
parent | 4c8336af67bf4e570e227d5cb1fbcb7a53b3776e (diff) | |
download | PeerTube-4fae2b1f300c1f027629569817262f60873a663a.tar.gz PeerTube-4fae2b1f300c1f027629569817262f60873a663a.tar.zst PeerTube-4fae2b1f300c1f027629569817262f60873a663a.zip |
Rename video full loading
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 () { | |||
70 | } | 70 | } |
71 | 71 | ||
72 | for (const id of ids) { | 72 | for (const id of ids) { |
73 | const videoFull = await VideoModel.loadAndPopulateAccountAndServerAndTags(id) | 73 | const videoFull = await VideoModel.loadFull(id) |
74 | 74 | ||
75 | const files = videoFull.VideoFiles || [] | 75 | const files = videoFull.VideoFiles || [] |
76 | const hls = videoFull.getHLSPlaylist() | 76 | 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 () { | |||
43 | return | 43 | return |
44 | } | 44 | } |
45 | 45 | ||
46 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(uuid) | 46 | const video = await VideoModel.loadFull(uuid) |
47 | if (!video) throw new Error('Video not found.') | 47 | if (!video) throw new Error('Video not found.') |
48 | 48 | ||
49 | const dataInput: VideoTranscodingPayload[] = [] | 49 | 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) { | |||
97 | // Everything worked, we can save the playlist now | 97 | // Everything worked, we can save the playlist now |
98 | await playlist.save() | 98 | await playlist.save() |
99 | 99 | ||
100 | const allVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.id) | 100 | const allVideo = await VideoModel.loadFull(video.id) |
101 | await federateVideoIfNeeded(allVideo, false) | 101 | await federateVideoIfNeeded(allVideo, false) |
102 | 102 | ||
103 | console.log(`Successfully moved HLS files of ${video.name}.`) | 103 | 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 () { | |||
114 | 114 | ||
115 | const ids = await VideoModel.listLocalIds() | 115 | const ids = await VideoModel.listLocalIds() |
116 | for (const id of ids) { | 116 | for (const id of ids) { |
117 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id) | 117 | const video = await VideoModel.loadFull(id) |
118 | 118 | ||
119 | console.log('Updating video ' + video.uuid) | 119 | console.log('Updating video ' + video.uuid) |
120 | 120 | ||
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) { | |||
105 | const channel = res.locals.videoChannel | 105 | const channel = res.locals.videoChannel |
106 | 106 | ||
107 | // We need more attributes for federation | 107 | // We need more attributes for federation |
108 | const targetVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoChangeOwnership.Video.id, t) | 108 | const targetVideo = await VideoModel.loadFull(videoChangeOwnership.Video.id, t) |
109 | 109 | ||
110 | const oldVideoChannel = await VideoChannelModel.loadAndPopulateAccount(targetVideo.channelId, t) | 110 | const oldVideoChannel = await VideoChannelModel.loadAndPopulateAccount(targetVideo.channelId, t) |
111 | 111 | ||
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) { | |||
62 | try { | 62 | try { |
63 | const { videoInstanceUpdated, isNewVideo } = await sequelizeTypescript.transaction(async t => { | 63 | const { videoInstanceUpdated, isNewVideo } = await sequelizeTypescript.transaction(async t => { |
64 | // Refresh video since thumbnails to prevent concurrent updates | 64 | // Refresh video since thumbnails to prevent concurrent updates |
65 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoFromReq.id, t) | 65 | const video = await VideoModel.loadFull(videoFromReq.id, t) |
66 | 66 | ||
67 | const sequelizeOptions = { transaction: t } | 67 | const sequelizeOptions = { transaction: t } |
68 | const oldVideoChannel = video.VideoChannel | 68 | const oldVideoChannel = video.VideoChannel |
@@ -212,5 +212,5 @@ async function updateTorrentsMetadataIfNeeded (video: MVideoFullLight, videoInfo | |||
212 | } | 212 | } |
213 | 213 | ||
214 | // Refresh video since files have changed | 214 | // Refresh video since files have changed |
215 | return VideoModel.loadAndPopulateAccountAndServerAndTags(video.id) | 215 | return VideoModel.loadFull(video.id) |
216 | } | 216 | } |
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 | |||
272 | const job = await JobQueue.Instance.createJobWithPromise({ type: 'manage-video-torrent', payload }) | 272 | const job = await JobQueue.Instance.createJobWithPromise({ type: 'manage-video-torrent', payload }) |
273 | await job.finished() | 273 | await job.finished() |
274 | 274 | ||
275 | const refreshedVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.id) | 275 | const refreshedVideo = await VideoModel.loadFull(video.id) |
276 | if (!refreshedVideo) return | 276 | if (!refreshedVideo) return |
277 | 277 | ||
278 | // Only federate and notify after the torrent creation | 278 | // 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 | |||
35 | if (!onlyVideo.isOwned()) return | 35 | if (!onlyVideo.isOwned()) return |
36 | 36 | ||
37 | return sequelizeTypescript.transaction(async t => { | 37 | return sequelizeTypescript.transaction(async t => { |
38 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(onlyVideo.id, t) | 38 | const video = await VideoModel.loadFull(onlyVideo.id, t) |
39 | 39 | ||
40 | const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, activity.id, t) | 40 | const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, activity.id, t) |
41 | if (existingRate && existingRate.type === 'dislike') return | 41 | 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 | |||
34 | if (!onlyVideo.isOwned()) return | 34 | if (!onlyVideo.isOwned()) return |
35 | 35 | ||
36 | return sequelizeTypescript.transaction(async t => { | 36 | return sequelizeTypescript.transaction(async t => { |
37 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(onlyVideo.id, t) | 37 | const video = await VideoModel.loadFull(onlyVideo.id, t) |
38 | 38 | ||
39 | const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, activity.id, t) | 39 | const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, activity.id, t) |
40 | if (existingRate && existingRate.type === 'like') return | 40 | 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 | |||
63 | return sequelizeTypescript.transaction(async t => { | 63 | return sequelizeTypescript.transaction(async t => { |
64 | if (!byActor.Account) throw new Error('Unknown account ' + byActor.url) | 64 | if (!byActor.Account) throw new Error('Unknown account ' + byActor.url) |
65 | 65 | ||
66 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(onlyVideo.id, t) | 66 | const video = await VideoModel.loadFull(onlyVideo.id, t) |
67 | const rate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byActor.Account.id, video.id, likeActivity.id, t) | 67 | const rate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byActor.Account.id, video.id, likeActivity.id, t) |
68 | if (!rate || rate.type !== 'like') throw new Error(`Unknown like by account ${byActor.Account.id} for video ${video.id}.`) | 68 | if (!rate || rate.type !== 'like') throw new Error(`Unknown like by account ${byActor.Account.id} for video ${video.id}.`) |
69 | 69 | ||
@@ -87,7 +87,7 @@ async function processUndoDislike (byActor: MActorSignature, activity: ActivityU | |||
87 | return sequelizeTypescript.transaction(async t => { | 87 | return sequelizeTypescript.transaction(async t => { |
88 | if (!byActor.Account) throw new Error('Unknown account ' + byActor.url) | 88 | if (!byActor.Account) throw new Error('Unknown account ' + byActor.url) |
89 | 89 | ||
90 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(onlyVideo.id, t) | 90 | const video = await VideoModel.loadFull(onlyVideo.id, t) |
91 | const rate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byActor.Account.id, video.id, dislike.id, t) | 91 | const rate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byActor.Account.id, video.id, dislike.id, t) |
92 | if (!rate || rate.type !== 'dislike') throw new Error(`Unknown dislike by account ${byActor.Account.id} for video ${video.id}.`) | 92 | if (!rate || rate.type !== 'dislike') throw new Error(`Unknown dislike by account ${byActor.Account.id} for video ${video.id}.`) |
93 | 93 | ||
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 | |||
83 | return | 83 | return |
84 | } | 84 | } |
85 | 85 | ||
86 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(associatedVideo.id) | 86 | const video = await VideoModel.loadFull(associatedVideo.id) |
87 | const createActivity = buildCreateActivity(redundancyModel.url, byActor, redundancyModel.toActivityPubObject()) | 87 | const createActivity = buildCreateActivity(redundancyModel.url, byActor, redundancyModel.toActivityPubObject()) |
88 | 88 | ||
89 | return sendUndoVideoRelatedActivity({ | 89 | 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 | |||
92 | return | 92 | return |
93 | } | 93 | } |
94 | 94 | ||
95 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(associatedVideo.id) | 95 | const video = await VideoModel.loadFull(associatedVideo.id) |
96 | 96 | ||
97 | const activityBuilder = (audience: ActivityAudience) => { | 97 | const activityBuilder = (audience: ActivityAudience) => { |
98 | const redundancyObject = redundancyModel.toActivityPubObject() | 98 | 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 <string> { | |||
35 | if (videoCaption.isOwned()) throw new Error('Cannot load remote caption of owned video.') | 35 | if (videoCaption.isOwned()) throw new Error('Cannot load remote caption of owned video.') |
36 | 36 | ||
37 | // Used to fetch the path | 37 | // Used to fetch the path |
38 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoCaption.videoId) | 38 | const video = await VideoModel.loadFull(videoCaption.videoId) |
39 | if (!video) return undefined | 39 | if (!video) return undefined |
40 | 40 | ||
41 | const remoteUrl = videoCaption.getFileUrl(video) | 41 | 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 <string> { | |||
30 | 30 | ||
31 | // Key is the video UUID | 31 | // Key is the video UUID |
32 | protected async loadRemoteFile (key: string) { | 32 | protected async loadRemoteFile (key: string) { |
33 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(key) | 33 | const video = await VideoModel.loadFull(key) |
34 | if (!video) return undefined | 34 | if (!video) return undefined |
35 | 35 | ||
36 | if (video.isOwned()) throw new Error('Cannot load remote preview of owned video.') | 36 | 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 <string> { | |||
40 | if (file.getVideo().isOwned()) throw new Error('Cannot load remote file of owned video.') | 40 | if (file.getVideo().isOwned()) throw new Error('Cannot load remote file of owned video.') |
41 | 41 | ||
42 | // Used to fetch the path | 42 | // Used to fetch the path |
43 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(file.getVideo().id) | 43 | const video = await VideoModel.loadFull(file.getVideo().id) |
44 | if (!video) return undefined | 44 | if (!video) return undefined |
45 | 45 | ||
46 | const remoteUrl = file.getRemoteTorrentUrl(video) | 46 | 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) { | |||
17 | const payload = job.data as ActivitypubHttpFetcherPayload | 17 | const payload = job.data as ActivitypubHttpFetcherPayload |
18 | 18 | ||
19 | let video: MVideoFullLight | 19 | let video: MVideoFullLight |
20 | if (payload.videoId) video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoId) | 20 | if (payload.videoId) video = await VideoModel.loadFull(payload.videoId) |
21 | 21 | ||
22 | const fetcherType: { [ id in FetchType ]: (items: any[]) => Promise<any> } = { | 22 | const fetcherType: { [ id in FetchType ]: (items: any[]) => Promise<any> } = { |
23 | 'activity': items => processActivities(items, { outboxUrl: payload.uri, fromFetch: true }), | 23 | '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) { | |||
18 | const payload = job.data as VideoFileImportPayload | 18 | const payload = job.data as VideoFileImportPayload |
19 | logger.info('Processing video file import in job %d.', job.id) | 19 | logger.info('Processing video file import in job %d.', job.id) |
20 | 20 | ||
21 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID) | 21 | const video = await VideoModel.loadFull(payload.videoUUID) |
22 | // No video, maybe deleted? | 22 | // No video, maybe deleted? |
23 | if (!video) { | 23 | if (!video) { |
24 | logger.info('Do not process job %d, video does not exist.', job.id) | 24 | 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<string>, videoImport: MVid | |||
219 | if (previewModel) await video.addAndSaveThumbnail(previewModel, t) | 219 | if (previewModel) await video.addAndSaveThumbnail(previewModel, t) |
220 | 220 | ||
221 | // Now we can federate the video (reload from database, we need more attributes) | 221 | // Now we can federate the video (reload from database, we need more attributes) |
222 | const videoForFederation = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t) | 222 | const videoForFederation = await VideoModel.loadFull(video.uuid, t) |
223 | await federateVideoIfNeeded(videoForFederation, true, t) | 223 | await federateVideoIfNeeded(videoForFederation, true, t) |
224 | 224 | ||
225 | // Update video import object | 225 | // 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: { | |||
144 | await liveSession.save() | 144 | await liveSession.save() |
145 | 145 | ||
146 | // Remove old HLS playlist video files | 146 | // Remove old HLS playlist video files |
147 | const videoWithFiles = await VideoModel.loadAndPopulateAccountAndServerAndTags(liveVideo.id) | 147 | const videoWithFiles = await VideoModel.loadFull(liveVideo.id) |
148 | 148 | ||
149 | const hlsPlaylist = videoWithFiles.getHLSPlaylist() | 149 | const hlsPlaylist = videoWithFiles.getHLSPlaylist() |
150 | await VideoFileModel.removeHLSFilesOfVideoId(hlsPlaylist.id) | 150 | await VideoFileModel.removeHLSFilesOfVideoId(hlsPlaylist.id) |
@@ -241,7 +241,7 @@ async function cleanupLiveAndFederate (options: { | |||
241 | } | 241 | } |
242 | 242 | ||
243 | try { | 243 | try { |
244 | const fullVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.id) | 244 | const fullVideo = await VideoModel.loadFull(video.id) |
245 | return federateVideoIfNeeded(fullVideo, false, undefined) | 245 | return federateVideoIfNeeded(fullVideo, false, undefined) |
246 | } catch (err) { | 246 | } catch (err) { |
247 | logger.warn('Cannot federate live after cleanup', { videoId: video.id, err }) | 247 | 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) { | |||
44 | 44 | ||
45 | logger.info('Process video studio edition of %s in job %d.', payload.videoUUID, job.id, lTags) | 45 | logger.info('Process video studio edition of %s in job %d.', payload.videoUUID, job.id, lTags) |
46 | 46 | ||
47 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID) | 47 | const video = await VideoModel.loadFull(payload.videoUUID) |
48 | 48 | ||
49 | // No video, maybe deleted? | 49 | // No video, maybe deleted? |
50 | if (!video) { | 50 | 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) { | |||
42 | const payload = job.data as VideoTranscodingPayload | 42 | const payload = job.data as VideoTranscodingPayload |
43 | logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID)) | 43 | logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID)) |
44 | 44 | ||
45 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID) | 45 | const video = await VideoModel.loadFull(payload.videoUUID) |
46 | // No video, maybe deleted? | 46 | // No video, maybe deleted? |
47 | if (!video) { | 47 | if (!video) { |
48 | logger.info('Do not process job %d, video does not exist.', job.id, lTags(payload.videoUUID)) | 48 | logger.info('Do not process job %d, video does not exist.', job.id, lTags(payload.videoUUID)) |
@@ -180,7 +180,7 @@ async function onVideoFirstWebTorrentTranscoding ( | |||
180 | const { resolution, isPortraitMode, audioStream } = await videoArg.probeMaxQualityFile() | 180 | const { resolution, isPortraitMode, audioStream } = await videoArg.probeMaxQualityFile() |
181 | 181 | ||
182 | // Maybe the video changed in database, refresh it | 182 | // Maybe the video changed in database, refresh it |
183 | const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid) | 183 | const videoDatabase = await VideoModel.loadFull(videoArg.uuid) |
184 | // Video does not exist anymore | 184 | // Video does not exist anymore |
185 | if (!videoDatabase) return undefined | 185 | if (!videoDatabase) return undefined |
186 | 186 | ||
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 { | |||
351 | const videoId = live.videoId | 351 | const videoId = live.videoId |
352 | 352 | ||
353 | try { | 353 | try { |
354 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId) | 354 | const video = await VideoModel.loadFull(videoId) |
355 | 355 | ||
356 | logger.info('Will publish and federate live %s.', video.url, localLTags) | 356 | logger.info('Will publish and federate live %s.', video.url, localLTags) |
357 | 357 | ||
@@ -390,7 +390,7 @@ class LiveManager { | |||
390 | const { videoId, liveSession: liveSessionArg, cleanupNow = false } = options | 390 | const { videoId, liveSession: liveSessionArg, cleanupNow = false } = options |
391 | 391 | ||
392 | try { | 392 | try { |
393 | const fullVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId) | 393 | const fullVideo = await VideoModel.loadFull(videoId) |
394 | if (!fullVideo) return | 394 | if (!fullVideo) return |
395 | 395 | ||
396 | const live = await VideoLiveModel.loadByVideoId(fullVideo.id) | 396 | 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 ( | |||
35 | ) | 35 | ) |
36 | } | 36 | } |
37 | 37 | ||
38 | if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId) | 38 | if (fetchType === 'all') return VideoModel.loadFull(id, undefined, userId) |
39 | 39 | ||
40 | if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id) | 40 | if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id) |
41 | 41 | ||
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 () { | |||
83 | 83 | ||
84 | removeVideo: (id: number) => { | 84 | removeVideo: (id: number) => { |
85 | return sequelizeTypescript.transaction(async t => { | 85 | return sequelizeTypescript.transaction(async t => { |
86 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id, t) | 86 | const video = await VideoModel.loadFull(id, t) |
87 | 87 | ||
88 | await video.destroy({ transaction: t }) | 88 | await video.destroy({ transaction: t }) |
89 | }) | 89 | }) |
@@ -94,7 +94,7 @@ function buildVideosHelpers () { | |||
94 | }, | 94 | }, |
95 | 95 | ||
96 | getFiles: async (id: number | string) => { | 96 | getFiles: async (id: number | string) => { |
97 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id) | 97 | const video = await VideoModel.loadFull(id) |
98 | if (!video) return undefined | 98 | if (!video) return undefined |
99 | 99 | ||
100 | const webtorrentVideoFiles = (video.VideoFiles || []).map(f => ({ | 100 | const webtorrentVideoFiles = (video.VideoFiles || []).map(f => ({ |
@@ -178,14 +178,14 @@ function buildModerationHelpers () { | |||
178 | }, | 178 | }, |
179 | 179 | ||
180 | blacklistVideo: async (options: { videoIdOrUUID: number | string, createOptions: VideoBlacklistCreate }) => { | 180 | blacklistVideo: async (options: { videoIdOrUUID: number | string, createOptions: VideoBlacklistCreate }) => { |
181 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.videoIdOrUUID) | 181 | const video = await VideoModel.loadFull(options.videoIdOrUUID) |
182 | if (!video) return | 182 | if (!video) return |
183 | 183 | ||
184 | await blacklistVideo(video, options.createOptions) | 184 | await blacklistVideo(video, options.createOptions) |
185 | }, | 185 | }, |
186 | 186 | ||
187 | unblacklistVideo: async (options: { videoIdOrUUID: number | string }) => { | 187 | unblacklistVideo: async (options: { videoIdOrUUID: number | string }) => { |
188 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.videoIdOrUUID) | 188 | const video = await VideoModel.loadFull(options.videoIdOrUUID) |
189 | if (!video) return | 189 | if (!video) return |
190 | 190 | ||
191 | const videoBlacklist = await VideoBlacklistModel.loadByVideoId(video.id) | 191 | 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 { | |||
30 | 30 | ||
31 | for (const schedule of schedules) { | 31 | for (const schedule of schedules) { |
32 | await sequelizeTypescript.transaction(async t => { | 32 | await sequelizeTypescript.transaction(async t => { |
33 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(schedule.videoId, t) | 33 | const video = await VideoModel.loadFull(schedule.videoId, t) |
34 | 34 | ||
35 | logger.info('Executing scheduled video update on %s.', video.uuid) | 35 | logger.info('Executing scheduled video update on %s.', video.uuid) |
36 | 36 | ||
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 { | |||
26 | const views = await Redis.Instance.getLocalVideoViews(videoId) | 26 | const views = await Redis.Instance.getLocalVideoViews(videoId) |
27 | await Redis.Instance.deleteLocalVideoViews(videoId) | 27 | await Redis.Instance.deleteLocalVideoViews(videoId) |
28 | 28 | ||
29 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId) | 29 | const video = await VideoModel.loadFull(videoId) |
30 | if (!video) { | 30 | if (!video) { |
31 | logger.debug('Video %d does not exist anymore, skipping videos view addition.', videoId, lTags()) | 31 | logger.debug('Video %d does not exist anymore, skipping videos view addition.', videoId, lTags()) |
32 | continue | 32 | 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) { | |||
36 | const videoIds = await VideoModel.getAllIdsFromChannel(videoChannel) | 36 | const videoIds = await VideoModel.getAllIdsFromChannel(videoChannel) |
37 | 37 | ||
38 | for (const videoId of videoIds) { | 38 | for (const videoId of videoIds) { |
39 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId) | 39 | const video = await VideoModel.loadFull(videoId) |
40 | 40 | ||
41 | await federateVideoIfNeeded(video, false) | 41 | await federateVideoIfNeeded(video, false) |
42 | } | 42 | } |
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: { | |||
43 | 43 | ||
44 | return sequelizeTypescript.transaction(async t => { | 44 | return sequelizeTypescript.transaction(async t => { |
45 | // Maybe the video changed in database, refresh it | 45 | // Maybe the video changed in database, refresh it |
46 | const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t) | 46 | const videoDatabase = await VideoModel.loadFull(video.uuid, t) |
47 | // Video does not exist anymore | 47 | // Video does not exist anymore |
48 | if (!videoDatabase) return undefined | 48 | if (!videoDatabase) return undefined |
49 | 49 | ||
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 | |||
144 | 144 | ||
145 | const videoWithRights = (video as MVideoWithRights).VideoChannel?.Account?.userId | 145 | const videoWithRights = (video as MVideoWithRights).VideoChannel?.Account?.userId |
146 | ? video as MVideoWithRights | 146 | ? video as MVideoWithRights |
147 | : await VideoModel.loadAndPopulateAccountAndServerAndTags(video.id) | 147 | : await VideoModel.loadFull(video.id) |
148 | 148 | ||
149 | const privacy = videoWithRights.privacy | 149 | const privacy = videoWithRights.privacy |
150 | 150 | ||
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' | |||
13 | 13 | ||
14 | export type GetType = | 14 | export type GetType = |
15 | 'api' | | 15 | 'api' | |
16 | 'full-light' | | 16 | 'full' | |
17 | 'account-blacklist-files' | | 17 | 'account-blacklist-files' | |
18 | 'all-files' | | 18 | 'all-files' | |
19 | 'thumbnails' | | 19 | 'thumbnails' | |
@@ -40,7 +40,7 @@ export class VideoModelGetQueryBuilder { | |||
40 | 40 | ||
41 | private readonly videoModelBuilder: VideoModelBuilder | 41 | private readonly videoModelBuilder: VideoModelBuilder |
42 | 42 | ||
43 | private static readonly videoFilesInclude = new Set<GetType>([ 'api', 'full-light', 'account-blacklist-files', 'all-files' ]) | 43 | private static readonly videoFilesInclude = new Set<GetType>([ 'api', 'full', 'account-blacklist-files', 'all-files' ]) |
44 | 44 | ||
45 | constructor (protected readonly sequelize: Sequelize) { | 45 | constructor (protected readonly sequelize: Sequelize) { |
46 | this.videoQueryBuilder = new VideosModelGetQuerySubBuilder(sequelize) | 46 | this.videoQueryBuilder = new VideosModelGetQuerySubBuilder(sequelize) |
@@ -96,16 +96,16 @@ export class VideosModelGetQuerySubBuilder extends AbstractVideoQueryBuilder { | |||
96 | protected streamingPlaylistFilesQuery: string | 96 | protected streamingPlaylistFilesQuery: string |
97 | 97 | ||
98 | private static readonly trackersInclude = new Set<GetType>([ 'api' ]) | 98 | private static readonly trackersInclude = new Set<GetType>([ 'api' ]) |
99 | private static readonly liveInclude = new Set<GetType>([ 'api', 'full-light' ]) | 99 | private static readonly liveInclude = new Set<GetType>([ 'api', 'full' ]) |
100 | private static readonly scheduleUpdateInclude = new Set<GetType>([ 'api', 'full-light' ]) | 100 | private static readonly scheduleUpdateInclude = new Set<GetType>([ 'api', 'full' ]) |
101 | private static readonly tagsInclude = new Set<GetType>([ 'api', 'full-light' ]) | 101 | private static readonly tagsInclude = new Set<GetType>([ 'api', 'full' ]) |
102 | private static readonly userHistoryInclude = new Set<GetType>([ 'api', 'full-light' ]) | 102 | private static readonly userHistoryInclude = new Set<GetType>([ 'api', 'full' ]) |
103 | private static readonly accountInclude = new Set<GetType>([ 'api', 'full-light', 'account-blacklist-files' ]) | 103 | private static readonly accountInclude = new Set<GetType>([ 'api', 'full', 'account-blacklist-files' ]) |
104 | private static readonly ownerUserInclude = new Set<GetType>([ 'blacklist-rights' ]) | 104 | private static readonly ownerUserInclude = new Set<GetType>([ 'blacklist-rights' ]) |
105 | 105 | ||
106 | private static readonly blacklistedInclude = new Set<GetType>([ | 106 | private static readonly blacklistedInclude = new Set<GetType>([ |
107 | 'api', | 107 | 'api', |
108 | 'full-light', | 108 | 'full', |
109 | 'account-blacklist-files', | 109 | 'account-blacklist-files', |
110 | 'thumbnails-blacklist', | 110 | 'thumbnails-blacklist', |
111 | 'blacklist-rights' | 111 | 'blacklist-rights' |
@@ -113,7 +113,7 @@ export class VideosModelGetQuerySubBuilder extends AbstractVideoQueryBuilder { | |||
113 | 113 | ||
114 | private static readonly thumbnailsInclude = new Set<GetType>([ | 114 | private static readonly thumbnailsInclude = new Set<GetType>([ |
115 | 'api', | 115 | 'api', |
116 | 'full-light', | 116 | 'full', |
117 | 'account-blacklist-files', | 117 | 'account-blacklist-files', |
118 | 'all-files', | 118 | 'all-files', |
119 | 'thumbnails', | 119 | '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<Partial<AttributesOnly<VideoModel>>> { | |||
1352 | return queryBuilder.queryVideo({ url, transaction, type: 'account-blacklist-files' }) | 1352 | return queryBuilder.queryVideo({ url, transaction, type: 'account-blacklist-files' }) |
1353 | } | 1353 | } |
1354 | 1354 | ||
1355 | static loadAndPopulateAccountAndServerAndTags (id: number | string, t?: Transaction, userId?: number): Promise<MVideoFullLight> { | 1355 | static loadFull (id: number | string, t?: Transaction, userId?: number): Promise<MVideoFullLight> { |
1356 | const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize) | 1356 | const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize) |
1357 | 1357 | ||
1358 | return queryBuilder.queryVideo({ id, transaction: t, type: 'full-light', userId }) | 1358 | return queryBuilder.queryVideo({ id, transaction: t, type: 'full', userId }) |
1359 | } | 1359 | } |
1360 | 1360 | ||
1361 | static loadForGetAPI (parameters: { | 1361 | static loadForGetAPI (parameters: { |