ActivityPub-federated video streaming platform using P2P directly in your web browser
Don't fetch video associations we don't need
Chocobozzz4b53a0218fa7
diff --git a/server/core/controllers/activitypub/client.ts b/server/core/controllers/activitypub/client.tsindex e9f5974cbe..c6fe595f0f 100644--- a/server/core/controllers/activitypub/client.ts+++ b/server/core/controllers/activitypub/client.ts@@ -34,7 +34,7 @@ import {asyncMiddleware,executeIfActivityPub,videoChannelsHandleValidatorFactory,- videosCustomGetValidator,+ videoGetValidatorFactory,videosShareValidator} from '../../middlewares/index.js'import {@@ -109,7 +109,7 @@ activityPubClientRouter.get('/videos/watch/:id/comments',executeIfActivityPub,activityPubRateLimiter,- asyncMiddleware(videosCustomGetValidator('only-video-and-blacklist')),+ asyncMiddleware(videoGetValidatorFactory('with-blacklist')),asyncMiddleware(videoCommentsController))activityPubClientRouter.get(@@ -141,21 +141,21 @@ activityPubClientRouter.get(executeIfActivityPub,activityPubRateLimiter,cacheRoute(ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS),- asyncMiddleware(videosCustomGetValidator('all')),+ asyncMiddleware(videoGetValidatorFactory('full')),asyncMiddleware(videoController))activityPubClientRouter.get('/videos/watch/:id/activity',executeIfActivityPub,activityPubRateLimiter,- asyncMiddleware(videosCustomGetValidator('all')),+ asyncMiddleware(videoGetValidatorFactory('full')),asyncMiddleware(videoController))activityPubClientRouter.get('/videos/watch/:id/announces',executeIfActivityPub,activityPubRateLimiter,- asyncMiddleware(videosCustomGetValidator('only-video-and-blacklist')),+ asyncMiddleware(videoGetValidatorFactory('with-blacklist')),asyncMiddleware(videoAnnouncesController))activityPubClientRouter.get(@@ -169,21 +169,21 @@ activityPubClientRouter.get('/videos/watch/:id/likes',executeIfActivityPub,activityPubRateLimiter,- asyncMiddleware(videosCustomGetValidator('only-video-and-blacklist')),+ asyncMiddleware(videoGetValidatorFactory('with-blacklist')),asyncMiddleware(videoLikesController))activityPubClientRouter.get('/videos/watch/:id/dislikes',executeIfActivityPub,activityPubRateLimiter,- asyncMiddleware(videosCustomGetValidator('only-video-and-blacklist')),+ asyncMiddleware(videoGetValidatorFactory('with-blacklist')),asyncMiddleware(videoDislikesController))activityPubClientRouter.get('/videos/watch/:id/player-settings',executeIfActivityPub,activityPubRateLimiter,- asyncMiddleware(videosCustomGetValidator('only-video-and-blacklist')),+ asyncMiddleware(videoGetValidatorFactory('with-blacklist')),asyncMiddleware(videoPlayerSettingsController))@@ -203,7 +203,7 @@ activityPubClientRouter.get(activityPubRateLimiter,apVideoChaptersSetCacheKey,chaptersCacheRouteMiddleware(ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS),- asyncMiddleware(videosCustomGetValidator('only-video-and-blacklist')),+ asyncMiddleware(videoGetValidatorFactory('with-blacklist')),asyncMiddleware(videoChaptersController))@@ -332,7 +332,7 @@ function getAccountVideoRateFactory (rateType: VideoRateType) {}async function videoController (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoFullif (redirectIfNotOwned(video.url, res)) return@@ -355,13 +355,13 @@ async function videoAnnounceController (req: express.Request, res: express.Respoif (redirectIfNotOwned(share.url, res)) return- const activity = buildAnnounceWithVideoAudience(share.Actor, share, res.locals.videoAll)+ const activity = buildAnnounceWithVideoAudience(share.Actor, share, res.locals.videoWithBlacklist)return activityPubResponse(activityPubContextify(activity, 'Announce', getContextFilter()), res)}async function videoAnnouncesController (req: express.Request, res: express.Response) {- const video = res.locals.onlyVideo+ const video = res.locals.videoWithBlacklistif (redirectIfNotOwned(video.url, res)) return@@ -378,7 +378,7 @@ async function videoAnnouncesController (req: express.Request, res: express.Resp}async function videoLikesController (req: express.Request, res: express.Response) {- const video = res.locals.onlyVideo+ const video = res.locals.videoWithBlacklistif (redirectIfNotOwned(video.url, res)) return@@ -388,7 +388,7 @@ async function videoLikesController (req: express.Request, res: express.Response}async function videoDislikesController (req: express.Request, res: express.Response) {- const video = res.locals.onlyVideo+ const video = res.locals.videoWithBlacklistif (redirectIfNotOwned(video.url, res)) return@@ -398,7 +398,7 @@ async function videoDislikesController (req: express.Request, res: express.Respo}async function videoCommentsController (req: express.Request, res: express.Response) {- const video = res.locals.onlyVideo+ const video = res.locals.videoWithBlacklistif (redirectIfNotOwned(video.url, res)) return@@ -418,7 +418,7 @@ async function videoCommentsController (req: express.Request, res: express.Respo// ---------------------------------------------------------------------------async function videoPlayerSettingsController (req: express.Request, res: express.Response) {- const video = res.locals.onlyVideo+ const video = res.locals.videoWithBlacklistif (redirectIfNotOwned(video.url, res)) return@@ -494,7 +494,7 @@ async function videoCommentApprovedController (req: express.Request, res: expres}async function videoChaptersController (req: express.Request, res: express.Response) {- const video = res.locals.onlyVideo+ const video = res.locals.videoWithBlacklistif (redirectIfNotOwned(video.url, res)) returndiff --git a/server/core/controllers/api/abuse.ts b/server/core/controllers/api/abuse.tsindex 3734246ea7..c57c3426e8 100644--- a/server/core/controllers/api/abuse.ts+++ b/server/core/controllers/api/abuse.ts@@ -35,7 +35,8 @@ const abuseRouter = express.Router()abuseRouter.use(apiRateLimiter)-abuseRouter.get('/',+abuseRouter.get(+ '/',openapiOperationDoc({ operationId: 'getAbuses' }),authenticate,ensureUserHasRight(UserRight.MANAGE_ABUSES),@@ -46,32 +47,32 @@ abuseRouter.get('/',abuseListForAdminsValidator,asyncMiddleware(listAbusesForAdmins))-abuseRouter.put('/:id',+abuseRouter.put(+ '/:id',authenticate,ensureUserHasRight(UserRight.MANAGE_ABUSES),asyncMiddleware(abuseUpdateValidator),asyncRetryTransactionMiddleware(updateAbuse))-abuseRouter.post('/',- authenticate,- asyncMiddleware(abuseReportValidator),- asyncRetryTransactionMiddleware(reportAbuse)-)-abuseRouter.delete('/:id',+abuseRouter.post('/', authenticate, asyncMiddleware(abuseReportValidator), asyncRetryTransactionMiddleware(reportAbuse))+abuseRouter.delete(+ '/:id',authenticate,ensureUserHasRight(UserRight.MANAGE_ABUSES),asyncMiddleware(abuseGetValidator),asyncRetryTransactionMiddleware(deleteAbuse))-abuseRouter.get('/:id/messages',+abuseRouter.get(+ '/:id/messages',authenticate,asyncMiddleware(getAbuseValidator),checkAbuseValidForMessagesValidator,asyncRetryTransactionMiddleware(listAbuseMessages))-abuseRouter.post('/:id/messages',+abuseRouter.post(+ '/:id/messages',authenticate,asyncMiddleware(getAbuseValidator),checkAbuseValidForMessagesValidator,@@ -79,7 +80,8 @@ abuseRouter.post('/:id/messages',asyncRetryTransactionMiddleware(addAbuseMessage))-abuseRouter.delete('/:id/messages/:messageId',+abuseRouter.delete(+ '/:id/messages/:messageId',authenticate,asyncMiddleware(getAbuseValidator),checkAbuseValidForMessagesValidator,@@ -166,7 +168,7 @@ async function deleteAbuse (req: express.Request, res: express.Response) {}async function reportAbuse (req: express.Request, res: express.Response) {- const videoInstance = res.locals.videoAll+ const videoInstance = res.locals.videoFullconst commentInstance = res.locals.videoCommentFullconst accountInstance = res.locals.accountdiff --git a/server/core/controllers/api/metrics.ts b/server/core/controllers/api/metrics.tsindex 42299817fe..00567b7aa9 100644--- a/server/core/controllers/api/metrics.ts+++ b/server/core/controllers/api/metrics.ts@@ -8,10 +8,7 @@ const metricsRouter = express.Router()metricsRouter.use(apiRateLimiter)-metricsRouter.post('/playback',- asyncMiddleware(addPlaybackMetricValidator),- addPlaybackMetric-)+metricsRouter.post('/playback', asyncMiddleware(addPlaybackMetricValidator), addPlaybackMetric)// ---------------------------------------------------------------------------@@ -28,7 +25,7 @@ function addPlaybackMetric (req: express.Request, res: express.Response) {const body: PlaybackMetricCreate = req.body- OpenTelemetryMetrics.Instance.observePlaybackMetric(res.locals.onlyImmutableVideo, body)+ OpenTelemetryMetrics.Instance.observePlaybackMetric(res.locals.videoImmutable, body)return res.sendStatus(HttpStatusCode.NO_CONTENT_204)}diff --git a/server/core/controllers/api/player-settings.ts b/server/core/controllers/api/player-settings.tsindex 8065647a18..b6738442a5 100644--- a/server/core/controllers/api/player-settings.ts+++ b/server/core/controllers/api/player-settings.ts@@ -61,7 +61,7 @@ export {// ---------------------------------------------------------------------------async function getVideoPlayerSettings (req: express.Request, res: express.Response) {- const video = res.locals.onlyVideo || res.locals.videoAll+ const video = res.locals.videoWithRightsconst { videoSetting, channelSetting } = await PlayerSettingModel.loadByVideoIdOrChannelId({channelId: video.channelId,@@ -91,7 +91,7 @@ async function getChannelPlayerSettings (req: express.Request, res: express.Respasync function updateVideoPlayerSettings (req: express.Request, res: express.Response) {const body: PlayerVideoSettingsUpdate = req.body- const video = res.locals.videoAll+ const video = res.locals.videoFullconst setting = await upsertPlayerSettings({ user: res.locals.oauth.token.User, settings: body, channel: undefined, video })diff --git a/server/core/controllers/api/runners/jobs-files.ts b/server/core/controllers/api/runners/jobs-files.tsindex c849f762f8..a61fc34b72 100644--- a/server/core/controllers/api/runners/jobs-files.ts+++ b/server/core/controllers/api/runners/jobs-files.ts@@ -9,7 +9,7 @@ import {runnerJobGetVideoStudioTaskFileValidator,runnerJobGetVideoTranscodingFileValidator} from '@server/middlewares/validators/runners/job-files.js'-import { MVideoFileStreamingPlaylistVideo, MVideoFileVideo, MVideoFullLight } from '@server/types/models/index.js'+import { MVideoFileStreamingPlaylistVideo, MVideoFileVideo, MVideoFull } from '@server/types/models/index.js'import express from 'express'const lTags = loggerTagsFactory('api', 'runner')@@ -60,7 +60,7 @@ export {async function getMaxQualitySeparatedAudioFile (req: express.Request, res: express.Response) {const runnerJob = res.locals.runnerJobconst runner = runnerJob.Runner- const video = res.locals.videoAll+ const video = res.locals.videoFulllogger.info('Get max quality separated audio file of video %s of job %s for runner %s',@@ -78,7 +78,7 @@ async function getMaxQualitySeparatedAudioFile (req: express.Request, res: expreasync function getMaxQualityVideoFile (req: express.Request, res: express.Response) {const runnerJob = res.locals.runnerJobconst runner = runnerJob.Runner- const video = res.locals.videoAll+ const video = res.locals.videoFulllogger.info('Get max quality file of video %s of job %s for runner %s',@@ -94,7 +94,7 @@ async function getMaxQualityVideoFile (req: express.Request, res: express.Respon}async function serveVideoFile (options: {- video: MVideoFullLight+ video: MVideoFullfile: MVideoFileVideo | MVideoFileStreamingPlaylistVideoreq: express.Requestres: express.Response@@ -130,7 +130,7 @@ async function serveVideoFile (options: {function getMaxQualityVideoThumbnail (req: express.Request, res: express.Response) {const runnerJob = res.locals.runnerJobconst runner = runnerJob.Runner- const video = res.locals.videoAll+ const video = res.locals.videoFulllogger.info('Get max quality preview file of video %s of job %s for runner %s',@@ -148,7 +148,7 @@ function getMaxQualityVideoThumbnail (req: express.Request, res: express.Responsfunction getVideoStudioTaskFile (req: express.Request, res: express.Response) {const runnerJob = res.locals.runnerJobconst runner = runnerJob.Runner- const video = res.locals.videoAll+ const video = res.locals.videoFullconst filename = req.params.filenamelogger.info(diff --git a/server/core/controllers/api/server/redundancy.ts b/server/core/controllers/api/server/redundancy.tsindex e16f855933..29a80d1185 100644--- a/server/core/controllers/api/server/redundancy.ts+++ b/server/core/controllers/api/server/redundancy.ts@@ -22,14 +22,16 @@ import {const serverRedundancyRouter = express.Router()-serverRedundancyRouter.put('/redundancy/:host',+serverRedundancyRouter.put(+ '/redundancy/:host',authenticate,ensureUserHasRight(UserRight.MANAGE_SERVER_FOLLOW),asyncMiddleware(updateServerRedundancyValidator),asyncMiddleware(updateRedundancy))-serverRedundancyRouter.get('/redundancy/videos',+serverRedundancyRouter.get(+ '/redundancy/videos',authenticate,ensureUserHasRight(UserRight.MANAGE_VIDEOS_REDUNDANCIES),listVideoRedundanciesValidator,@@ -40,14 +42,16 @@ serverRedundancyRouter.get('/redundancy/videos',asyncMiddleware(listVideoRedundancies))-serverRedundancyRouter.post('/redundancy/videos',+serverRedundancyRouter.post(+ '/redundancy/videos',authenticate,ensureUserHasRight(UserRight.MANAGE_VIDEOS_REDUNDANCIES),addVideoRedundancyValidator,asyncMiddleware(addVideoRedundancy))-serverRedundancyRouter.delete('/redundancy/videos/:redundancyId',+serverRedundancyRouter.delete(+ '/redundancy/videos/:redundancyId',authenticate,ensureUserHasRight(UserRight.MANAGE_VIDEOS_REDUNDANCIES),removeVideoRedundancyValidator,@@ -81,7 +85,7 @@ async function listVideoRedundancies (req: express.Request, res: express.Responsasync function addVideoRedundancy (req: express.Request, res: express.Response) {const payload = {- videoId: res.locals.onlyVideo.id+ videoId: res.locals.videoWithBlacklist.id}await JobQueue.Instance.createJob({diff --git a/server/core/controllers/api/users/me.ts b/server/core/controllers/api/users/me.tsindex 5660e292df..7dbfca8b9f 100644--- a/server/core/controllers/api/users/me.ts+++ b/server/core/controllers/api/users/me.ts@@ -204,7 +204,7 @@ async function listCommentsOnUserVideos (req: express.Request, res: express.RespheldForReview: req.query.isHeldForReview,videoChannelOwnerId: res.locals.videoChannel?.id,- videoId: res.locals.videoAll?.id+ videoId: res.locals.videoWithRights?.id})return res.json({diff --git a/server/core/controllers/api/video-playlist.ts b/server/core/controllers/api/video-playlist.tsindex af9d62d9e9..aa287c0ab7 100644--- a/server/core/controllers/api/video-playlist.ts+++ b/server/core/controllers/api/video-playlist.ts@@ -415,7 +415,7 @@ async function removeVideoPlaylist (req: express.Request, res: express.Response)async function addVideoInPlaylist (req: express.Request, res: express.Response) {const body: VideoPlaylistElementCreate = req.bodyconst videoPlaylist = res.locals.videoPlaylistFull- const video = res.locals.onlyVideo+ const video = res.locals.videoThumbnailsconst playlistElement = await sequelizeTypescript.transaction(async t => {const position = await VideoPlaylistElementModel.getNextPositionOf(videoPlaylist.id, t)diff --git a/server/core/controllers/api/videos/blacklist.ts b/server/core/controllers/api/videos/blacklist.tsindex 1facbc5d3f..e93eeae9c9 100644--- a/server/core/controllers/api/videos/blacklist.ts+++ b/server/core/controllers/api/videos/blacklist.ts@@ -22,7 +22,8 @@ import { VideoBlacklistModel } from '../../../models/video/video-blacklist.js'const blacklistRouter = express.Router()-blacklistRouter.post('/:videoId/blacklist',+blacklistRouter.post(+ '/:videoId/blacklist',openapiOperationDoc({ operationId: 'addVideoBlock' }),authenticate,ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),@@ -30,7 +31,8 @@ blacklistRouter.post('/:videoId/blacklist',asyncMiddleware(addVideoToBlacklistController))-blacklistRouter.get('/blacklist',+blacklistRouter.get(+ '/blacklist',openapiOperationDoc({ operationId: 'getVideoBlocks' }),authenticate,ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),@@ -42,14 +44,16 @@ blacklistRouter.get('/blacklist',asyncMiddleware(listBlacklist))-blacklistRouter.put('/:videoId/blacklist',+blacklistRouter.put(+ '/:videoId/blacklist',authenticate,ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),asyncMiddleware(videosBlacklistUpdateValidator),asyncMiddleware(updateVideoBlacklistController))-blacklistRouter.delete('/:videoId/blacklist',+blacklistRouter.delete(+ '/:videoId/blacklist',openapiOperationDoc({ operationId: 'delVideoBlock' }),authenticate,ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),@@ -66,7 +70,7 @@ export {// ---------------------------------------------------------------------------async function addVideoToBlacklistController (req: express.Request, res: express.Response) {- const videoInstance = res.locals.videoAll+ const videoInstance = res.locals.videoWithRightsconst body: VideoBlacklistCreate = req.bodyawait blacklistVideo(videoInstance, body)@@ -102,7 +106,7 @@ async function listBlacklist (req: express.Request, res: express.Response) {async function removeVideoFromBlacklistController (req: express.Request, res: express.Response) {const videoBlacklist = res.locals.videoBlacklist- const video = res.locals.videoAll+ const video = res.locals.videoWithRightsawait unblacklistVideo(videoBlacklist, video)diff --git a/server/core/controllers/api/videos/captions.ts b/server/core/controllers/api/videos/captions.tsindex e43ac4ec2b..bae110d44c 100644--- a/server/core/controllers/api/videos/captions.ts+++ b/server/core/controllers/api/videos/captions.ts@@ -2,6 +2,7 @@ import { HttpStatusCode, VideoCaptionGenerate, VideoChannelActivityAction } fromimport { retryTransactionWrapper } from '@server/helpers/database-utils.js'import { Hooks } from '@server/lib/plugins/hooks.js'import { createLocalCaption, createTranscriptionTaskIfNeeded, updateHLSMasterOnCaptionChangeIfNeeded } from '@server/lib/video-captions.js'+import { VideoChannelActivityModel } from '@server/models/video/video-channel-activity.js'import { VideoJobInfoModel } from '@server/models/video/video-job-info.js'import express from 'express'import { createReqFiles } from '../../../helpers/express-utils.js'@@ -18,7 +19,6 @@ import {listVideoCaptionsValidator} from '../../../middlewares/validators/index.js'import { VideoCaptionModel } from '../../../models/video/video-caption.js'-import { VideoChannelActivityModel } from '@server/models/video/video-channel-activity.js'const lTags = loggerTagsFactory('api', 'video-caption')@@ -59,7 +59,7 @@ export {// ---------------------------------------------------------------------------async function createGenerateVideoCaption (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoWithRightsconst body = req.body as VideoCaptionGenerateif (body.forceTranscription === true) {@@ -72,14 +72,14 @@ async function createGenerateVideoCaption (req: express.Request, res: express.Re}async function listVideoCaptions (req: express.Request, res: express.Response) {- const data = await VideoCaptionModel.listVideoCaptions(res.locals.onlyVideo.id)+ const data = await VideoCaptionModel.listVideoCaptions(res.locals.videoWithBlacklist.id)return res.json(getFormattedObjects(data, data.length))}async function createVideoCaption (req: express.Request, res: express.Response) {const videoCaptionPhysicalFile: Express.Multer.File = req.files['captionfile'][0]- const video = res.locals.videoAll+ const video = res.locals.videoFullconst captionLanguage = req.params.captionLanguage@@ -114,7 +114,7 @@ async function createVideoCaption (req: express.Request, res: express.Response)}async function deleteVideoCaption (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoFullconst videoCaption = res.locals.videoCaptionconst hasM3U8 = !!videoCaption.m3u8Filenamediff --git a/server/core/controllers/api/videos/chapters.ts b/server/core/controllers/api/videos/chapters.tsindex d80f766d26..91a8bc9261 100644--- a/server/core/controllers/api/videos/chapters.ts+++ b/server/core/controllers/api/videos/chapters.ts@@ -7,13 +7,13 @@ import { VideoChannelActivityModel } from '@server/models/video/video-channel-acimport { VideoChapterModel } from '@server/models/video/video-chapter.js'import express from 'express'import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares/index.js'-import { updateVideoChaptersValidator, videosCustomGetValidator } from '../../../middlewares/validators/index.js'+import { updateVideoChaptersValidator, videoGetValidatorFactory } from '../../../middlewares/validators/index.js'const videoChaptersRouter = express.Router()videoChaptersRouter.get('/:id/chapters',- asyncMiddleware(videosCustomGetValidator('only-video-and-blacklist')),+ asyncMiddleware(videoGetValidatorFactory('with-blacklist')),asyncMiddleware(listVideoChapters))@@ -33,14 +33,14 @@ export {// ---------------------------------------------------------------------------async function listVideoChapters (req: express.Request, res: express.Response) {- const chapters = await VideoChapterModel.listChaptersOfVideo(res.locals.onlyVideo.id)+ const chapters = await VideoChapterModel.listChaptersOfVideo(res.locals.videoWithBlacklist.id)return res.json({ chapters: chapters.map(c => c.toFormattedJSON()) })}async function replaceVideoChapters (req: express.Request, res: express.Response) {const body = req.body as VideoChapterUpdate- const video = res.locals.videoAll+ const video = res.locals.videoFullawait retryTransactionWrapper(() => {return sequelizeTypescript.transaction(async t => {diff --git a/server/core/controllers/api/videos/comment.ts b/server/core/controllers/api/videos/comment.tsindex f74c38cd6b..0b0a31b855 100644--- a/server/core/controllers/api/videos/comment.ts+++ b/server/core/controllers/api/videos/comment.ts@@ -119,7 +119,7 @@ async function listComments (req: express.Request, res: express.Response) {'autoTagOneOf']),- videoId: res.locals.onlyImmutableVideo?.id,+ videoId: res.locals.videoImmutable?.id,videoChannelOwnerId: res.locals.videoChannel?.id,autoTagOfAccountId: (await getServerActor()).Account.id,heldForReview: undefined@@ -134,7 +134,7 @@ async function listComments (req: express.Request, res: express.Response) {}async function listVideoThreads (req: express.Request, res: express.Response) {- const video = res.locals.onlyVideo+ const video = res.locals.videoWithBlacklistconst user = res.locals.oauth ? res.locals.oauth.token.User : undefinedlet resultList: ThreadsResultList<MCommentFormattable>@@ -168,7 +168,7 @@ async function listVideoThreads (req: express.Request, res: express.Response) {}async function listVideoThreadComments (req: express.Request, res: express.Response) {- const video = res.locals.onlyVideo+ const video = res.locals.videoWithBlacklistconst user = res.locals.oauth ? res.locals.oauth.token.User : undefinedlet resultList: ResultList<MCommentFormattable>@@ -208,7 +208,7 @@ async function addVideoCommentThread (req: express.Request, res: express.Responsconst comment = await createLocalVideoComment({text: videoCommentInfo.text,inReplyToComment: null,- video: res.locals.videoAll,+ video: res.locals.videoWithRights,user: res.locals.oauth.token.User})@@ -226,7 +226,7 @@ async function addVideoCommentReply (req: express.Request, res: express.Responseconst comment = await createLocalVideoComment({text: videoCommentInfo.text,inReplyToComment: res.locals.videoCommentFull,- video: res.locals.videoAll,+ video: res.locals.videoWithRights,user: res.locals.oauth.token.User})diff --git a/server/core/controllers/api/videos/embed-privacy.ts b/server/core/controllers/api/videos/embed-privacy.tsindex 4d4a8fd7e5..f327294ab5 100644--- a/server/core/controllers/api/videos/embed-privacy.ts+++ b/server/core/controllers/api/videos/embed-privacy.ts@@ -58,8 +58,8 @@ export {// ---------------------------------------------------------------------------async function getVideoEmbedPrivacy (req: express.Request, res: express.Response) {- const domains = await VideoEmbedPrivacyDomainModel.list(res.locals.videoAll.id)- const video = res.locals.videoAll+ const video = res.locals.videoWithRights+ const domains = await VideoEmbedPrivacyDomainModel.list(video.id)return res.json({@@ -73,7 +73,7 @@ async function getVideoEmbedPrivacy (req: express.Request, res: express.Response}async function isVideoEmbedOnDomainAllowed (req: express.Request, res: express.Response) {- const video = res.locals.onlyVideo+ const video = res.locals.videoWithBlacklistconst domainAllowed = video.embedPrivacyPolicy === VideoEmbedPrivacyPolicy.ALL_ALLOWED? true@@ -88,7 +88,7 @@ async function isVideoEmbedOnDomainAllowed (req: express.Request, res: express.Rif (domainAllowed === false && user) {userBypassAllowed = await checkCanManageVideo({user,- video: await VideoModel.loadFull(video.id),+ video: await VideoModel.loadWithRights(video.id),right: UserRight.UPDATE_ANY_VIDEO,checkIsOwner: false,checkIsLocal: false,@@ -101,7 +101,7 @@ async function isVideoEmbedOnDomainAllowed (req: express.Request, res: express.R}async function updateVideoEmbedPrivacy (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoFullconst body = req.body as VideoEmbedPrivacyUpdateawait VideoPasswordModel.sequelize.transaction(async (t: Transaction) => {diff --git a/server/core/controllers/api/videos/files.ts b/server/core/controllers/api/videos/files.tsindex b9149ffb41..e7c767d771 100644--- a/server/core/controllers/api/videos/files.ts+++ b/server/core/controllers/api/videos/files.ts@@ -15,38 +15,43 @@ import {videoFilesDeleteHLSValidator,videoFilesDeleteWebVideoFileValidator,videoFilesDeleteWebVideoValidator,- videosGetValidator+ videoGetValidatorFactory} from '../../../middlewares/index.js'const lTags = loggerTagsFactory('api', 'video')const filesRouter = express.Router()-filesRouter.get('/:id/metadata/:videoFileId',- asyncMiddleware(videosGetValidator),+filesRouter.get(+ '/:id/metadata/:videoFileId',+ asyncMiddleware(videoGetValidatorFactory('with-blacklist')),asyncMiddleware(videoFileMetadataGetValidator),asyncMiddleware(getVideoFileMetadata))-filesRouter.delete('/:id/hls',+filesRouter.delete(+ '/:id/hls',authenticate,ensureUserHasRight(UserRight.MANAGE_VIDEO_FILES),asyncMiddleware(videoFilesDeleteHLSValidator),asyncMiddleware(removeHLSPlaylistController))-filesRouter.delete('/:id/hls/:videoFileId',+filesRouter.delete(+ '/:id/hls/:videoFileId',authenticate,ensureUserHasRight(UserRight.MANAGE_VIDEO_FILES),asyncMiddleware(videoFilesDeleteHLSFileValidator),asyncMiddleware(removeHLSFileController))-filesRouter.delete('/:id/web-videos',+filesRouter.delete(+ '/:id/web-videos',authenticate,ensureUserHasRight(UserRight.MANAGE_VIDEO_FILES),asyncMiddleware(videoFilesDeleteWebVideoValidator),asyncMiddleware(removeAllWebVideoFilesController))-filesRouter.delete('/:id/web-videos/:videoFileId',+filesRouter.delete(+ '/:id/web-videos/:videoFileId',authenticate,ensureUserHasRight(UserRight.MANAGE_VIDEO_FILES),asyncMiddleware(videoFilesDeleteWebVideoFileValidator),@@ -70,7 +75,7 @@ async function getVideoFileMetadata (req: express.Request, res: express.Response// ---------------------------------------------------------------------------async function removeHLSPlaylistController (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoFulllogger.info('Deleting HLS playlist of %s.', video.url, lTags(video.uuid))await removeHLSPlaylist(video)@@ -81,7 +86,7 @@ async function removeHLSPlaylistController (req: express.Request, res: express.R}async function removeHLSFileController (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoFullconst videoFileId = +req.params.videoFileIdlogger.info('Deleting HLS file %d of %s.', videoFileId, video.url, lTags(video.uuid))@@ -97,7 +102,7 @@ async function removeHLSFileController (req: express.Request, res: express.Respo// ---------------------------------------------------------------------------async function removeAllWebVideoFilesController (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoFulllogger.info('Deleting Web Video files of %s.', video.url, lTags(video.uuid))@@ -108,7 +113,7 @@ async function removeAllWebVideoFilesController (req: express.Request, res: expr}async function removeWebVideoFileController (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoFullconst videoFileId = +req.params.videoFileIdlogger.info('Deleting Web Video file %d of %s.', videoFileId, video.url, lTags(video.uuid))diff --git a/server/core/controllers/api/videos/import.ts b/server/core/controllers/api/videos/import.tsindex 152c5c070f..6a23339b14 100644--- a/server/core/controllers/api/videos/import.ts+++ b/server/core/controllers/api/videos/import.ts@@ -11,7 +11,7 @@ import { YoutubeDlImportError, YoutubeDlImportErrorCode } from '@server/helpers/import { createLocalVideoThumbnailsFromImage } from '@server/lib/thumbnail.js'import { buildRetryImportJob } from '@server/lib/video-post-import.js'import { buildVideoFromImport, buildYoutubeDLImport, insertFromImportIntoDB } from '@server/lib/video-pre-import.js'-import { MVideoThumbnail } from '@server/types/models/index.js'+import { MVideoThumbnails } from '@server/types/models/index.js'import express from 'express'import { move } from 'fs-extra/esm'import { readFile } from 'fs/promises'@@ -223,7 +223,7 @@ async function handleYoutubeDlImport (req: express.Request, res: express.Respons}}-function processThumbnails (req: express.Request, video: MVideoThumbnail) {+function processThumbnails (req: express.Request, video: MVideoThumbnails) {const file = getVideoThumbnailFile(req.files)if (!file) return []diff --git a/server/core/controllers/api/videos/index.ts b/server/core/controllers/api/videos/index.tsindex 7040c59333..b462452f12 100644--- a/server/core/controllers/api/videos/index.ts+++ b/server/core/controllers/api/videos/index.ts@@ -23,7 +23,7 @@ import {paginationValidator,setDefaultPagination,setDefaultVideosSort,- videosCustomGetValidator,+ videoGetValidatorFactory,videosRemoveValidator,videosSortValidator} from '../../../middlewares/index.js'@@ -97,7 +97,7 @@ videosRouter.get('/:id',openapiOperationDoc({ operationId: 'getVideo' }),optionalAuthenticate,- asyncMiddleware(videosCustomGetValidator('for-api')),+ asyncMiddleware(videoGetValidatorFactory('for-api')),asyncMiddleware(checkVideoFollowConstraints),asyncMiddleware(getVideo))@@ -175,7 +175,7 @@ async function listVideos (req: express.Request, res: express.Response) {}async function removeVideo (req: express.Request, res: express.Response) {- const videoInstance = res.locals.videoAll+ const videoInstance = res.locals.videoFullawait sequelizeTypescript.transaction(async t => {await videoInstance.destroy({ transaction: t })diff --git a/server/core/controllers/api/videos/live.ts b/server/core/controllers/api/videos/live.tsindex 8e95d8f783..ea3883ca71 100644--- a/server/core/controllers/api/videos/live.ts+++ b/server/core/controllers/api/videos/live.ts@@ -22,7 +22,7 @@ import { checkCanManageVideo } from '@server/middlewares/validators/shared/videoimport {videoLiveAddValidator,videoLiveFindReplaySessionValidator,- videoLiveGetValidator,+ videoLiveGetValidatorFactory,videoLiveListSessionsValidator,videoLiveUpdateValidator} from '@server/middlewares/validators/videos/video-live.js'@@ -62,7 +62,7 @@ liveRouter.get(authenticate,liveSessionsSortValidator,setLiveSessionsSort,- asyncMiddleware(videoLiveGetValidator),+ asyncMiddleware(videoLiveGetValidatorFactory('with-rights')),asyncMiddleware(videoLiveListSessionsValidator),asyncMiddleware(listLiveVideoSessions))@@ -70,14 +70,14 @@ liveRouter.get(liveRouter.get('/live/:videoId',optionalAuthenticate,- asyncMiddleware(videoLiveGetValidator),+ asyncMiddleware(videoLiveGetValidatorFactory('with-rights')),asyncMiddleware(getLiveVideo))liveRouter.put('/live/:videoId',authenticate,- asyncMiddleware(videoLiveGetValidator),+ asyncMiddleware(videoLiveGetValidatorFactory('full')),asyncMiddleware(videoLiveUpdateValidator),asyncRetryTransactionMiddleware(updateLiveVideo))@@ -99,7 +99,17 @@ export {async function getLiveVideo (req: express.Request, res: express.Response) {const videoLive = res.locals.videoLive- return res.json(videoLive.toFormattedJSON(await canSeePrivateLiveInformation(req, res)))+ const canSeePrivateLiveInformation = await checkCanManageVideo({+ user: res.locals.oauth?.token.User,+ video: res.locals.videoWithRights,+ right: UserRight.GET_ANY_LIVE,+ req,+ res: null,+ checkIsLocal: true,+ checkIsOwner: false+ })++ return res.json(videoLive.toFormattedJSON(canSeePrivateLiveInformation))}function getLiveReplaySession (req: express.Request, res: express.Response) {@@ -120,22 +130,10 @@ async function listLiveVideoSessions (req: express.Request, res: express.Responsreturn res.json(getFormattedObjects(data, data.length))}-function canSeePrivateLiveInformation (req: express.Request, res: express.Response) {- return checkCanManageVideo({- user: res.locals.oauth?.token.User,- video: res.locals.videoAll,- right: UserRight.GET_ANY_LIVE,- req,- res: null,- checkIsLocal: true,- checkIsOwner: false- })-}-async function updateLiveVideo (req: express.Request, res: express.Response) {const body: LiveVideoUpdate = req.body- const video = res.locals.videoAll+ const video = res.locals.videoFullconst videoLive = res.locals.videoLiveawait retryTransactionWrapper(() => {diff --git a/server/core/controllers/api/videos/ownership.ts b/server/core/controllers/api/videos/ownership.tsindex b850003694..0806aa402d 100644--- a/server/core/controllers/api/videos/ownership.ts+++ b/server/core/controllers/api/videos/ownership.ts@@ -1,7 +1,7 @@import { HttpStatusCode, VideoChangeOwnershipStatus, VideoChannelActivityAction } from '@peertube/peertube-models'import { canVideoBeFederated } from '@server/lib/activitypub/videos/federate.js'import { VideoChannelActivityModel } from '@server/models/video/video-channel-activity.js'-import { MVideoFullLight } from '@server/types/models/index.js'+import { MVideoFull } from '@server/types/models/index.js'import express from 'express'import { logger } from '../../../helpers/logger.js'import { getFormattedObjects } from '../../../helpers/utils.js'@@ -63,7 +63,7 @@ export {// ---------------------------------------------------------------------------async function giveVideoOwnership (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoWithRightsconst initiatorAccountId = res.locals.oauth.token.User.Account.idconst nextOwner = res.locals.videoChangeOwnershipNextOwner@@ -124,7 +124,7 @@ function acceptOwnership (req: express.Request, res: express.Response) {targetVideo.channelId = channel.id- const targetVideoUpdated = await targetVideo.save({ transaction: t }) as MVideoFullLight+ const targetVideoUpdated = await targetVideo.save({ transaction: t }) as MVideoFulltargetVideoUpdated.VideoChannel = channelif (canVideoBeFederated(targetVideoUpdated)) {diff --git a/server/core/controllers/api/videos/passwords.ts b/server/core/controllers/api/videos/passwords.tsindex 3c20c83dbd..e4102f5fa8 100644--- a/server/core/controllers/api/videos/passwords.ts+++ b/server/core/controllers/api/videos/passwords.ts@@ -62,7 +62,7 @@ export {async function listVideoPasswords (req: express.Request, res: express.Response) {const options = {- videoId: res.locals.videoAll.id,+ videoId: res.locals.videoWithRights.id,start: req.query.start,count: req.query.count,sort: req.query.sort@@ -74,7 +74,7 @@ async function listVideoPasswords (req: express.Request, res: express.Response)}async function updateVideoPasswordList (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoWithRightsconst videoId = video.idconst passwordArray = req.body.passwords as string[]@@ -98,7 +98,7 @@ async function updateVideoPasswordList (req: express.Request, res: express.Respo}async function addVideoPassword (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoWithRightsconst videoId = video.idconst newPassword = req.body.password as string@@ -113,7 +113,7 @@ async function addVideoPassword (req: express.Request, res: express.Response) {}async function removeVideoPassword (req: express.Request, res: express.Response) {- const videoInstance = res.locals.videoAll+ const videoInstance = res.locals.videoWithRightsconst password = res.locals.videoPasswordawait VideoPasswordModel.deletePassword(password.id)diff --git a/server/core/controllers/api/videos/rate.ts b/server/core/controllers/api/videos/rate.tsindex a75fc7f79e..992c7ef496 100644--- a/server/core/controllers/api/videos/rate.ts+++ b/server/core/controllers/api/videos/rate.ts@@ -6,7 +6,8 @@ import { userRateVideo } from '@server/lib/rate.js'const rateVideoRouter = express.Router()-rateVideoRouter.put('/:id/rate',+rateVideoRouter.put(+ '/:id/rate',authenticate,asyncMiddleware(videoUpdateRateValidator),asyncRetryTransactionMiddleware(rateVideo)@@ -22,7 +23,7 @@ export {async function rateVideo (req: express.Request, res: express.Response) {const user = res.locals.oauth.token.User- const video = res.locals.videoAll+ const video = res.locals.videoFullawait userRateVideo({account: user.Account,diff --git a/server/core/controllers/api/videos/source.ts b/server/core/controllers/api/videos/source.tsindex e887f19ef5..fa25178923 100644--- a/server/core/controllers/api/videos/source.ts+++ b/server/core/controllers/api/videos/source.ts@@ -1,7 +1,7 @@import { buildAspectRatio } from '@peertube/peertube-core-utils'import { HttpStatusCode, VideoChannelActivityAction, VideoState } from '@peertube/peertube-models'import { sequelizeTypescript } from '@server/initializers/database.js'-import { CreateJobTypeAndPayload, CreateJobOptions, JobQueue } from '@server/lib/job-queue/index.js'+import { CreateJobOptions, CreateJobTypeAndPayload, JobQueue } from '@server/lib/job-queue/index.js'import { Hooks } from '@server/lib/plugins/hooks.js'import { regenerateLocalVideoThumbnailsFromVideoIfNeeded } from '@server/lib/thumbnail.js'import { setupUploadResumableRoutes } from '@server/lib/uploadx.js'@@ -14,7 +14,7 @@ import { buildNextVideoState } from '@server/lib/video-state.js'import { openapiOperationDoc } from '@server/middlewares/doc.js'import { VideoChannelActivityModel } from '@server/models/video/video-channel-activity.js'import { VideoModel } from '@server/models/video/video.js'-import { MStreamingPlaylistFiles, MVideo, MVideoFile, MVideoFullLight } from '@server/types/models/index.js'+import { MStreamingPlaylistFiles, MVideo, MVideoFile, MVideoFull } from '@server/types/models/index.js'import express from 'express'import { move } from 'fs-extra/esm'import { logger, loggerTagsFactory } from '../../../helpers/logger.js'@@ -65,7 +65,7 @@ export {async function deleteVideoLatestSourceFile (req: express.Request, res: express.Response) {const videoSource = res.locals.videoSource- const video = res.locals.videoAll+ const video = res.locals.videoWithRightsawait video.removeOriginalFile(videoSource)@@ -96,10 +96,10 @@ async function replaceVideoSourceResumable (req: express.Request, res: express.Rconst videoFile = await buildNewFile({ path: videoPhysicalFile.path, mode: 'web-video', ffprobe: res.locals.ffprobe })const originalFilename = videoPhysicalFile.originalname- const videoFileMutexReleaser = await VideoPathManager.Instance.lockFiles(res.locals.videoAll.uuid)+ const videoFileMutexReleaser = await VideoPathManager.Instance.lockFiles(res.locals.videoFull.uuid)try {- const destination = VideoPathManager.Instance.getFSVideoFileOutputPath(res.locals.videoAll, videoFile)+ const destination = VideoPathManager.Instance.getFSVideoFileOutputPath(res.locals.videoFull, videoFile)await move(videoPhysicalFile.path, destination)let oldWebVideoFiles: MVideoFile[] = []@@ -108,7 +108,7 @@ async function replaceVideoSourceResumable (req: express.Request, res: express.Rconst inputFileUpdatedAt = new Date()const video = await sequelizeTypescript.transaction(async transaction => {- const video = await VideoModel.loadFull(res.locals.videoAll.id, transaction)+ const video = await VideoModel.loadFull(res.locals.videoFull.id, transaction)oldWebVideoFiles = video.VideoFilesoldStreamingPlaylists = video.VideoStreamingPlaylists@@ -177,7 +177,7 @@ async function replaceVideoSourceResumable (req: express.Request, res: express.R}}-async function addVideoJobsAfterUpload (video: MVideoFullLight, videoFile: MVideoFile) {+async function addVideoJobsAfterUpload (video: MVideoFull, videoFile: MVideoFile) {const jobs: (CreateJobTypeAndPayload & CreateJobOptions)[] = [{type: 'manage-video-torrent' as const,diff --git a/server/core/controllers/api/videos/stats.ts b/server/core/controllers/api/videos/stats.tsindex 8ff3448b63..19187a327c 100644--- a/server/core/controllers/api/videos/stats.ts+++ b/server/core/controllers/api/videos/stats.ts@@ -54,7 +54,7 @@ export {// ---------------------------------------------------------------------------async function getOverallStats (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoWithRightsconst query = req.query as VideoStatsOverallQueryconst stats = await LocalVideoViewerModel.getOverallStats({@@ -67,7 +67,7 @@ async function getOverallStats (req: express.Request, res: express.Response) {}async function getUserAgentStats (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoWithRightsconst query = req.query as VideoStatsUserAgentQueryconst stats = await LocalVideoViewerModel.getUserAgentStats({@@ -80,7 +80,7 @@ async function getUserAgentStats (req: express.Request, res: express.Response) {}async function getRetentionStats (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoWithRightsconst stats = await LocalVideoViewerModel.getRetentionStats(video)@@ -88,7 +88,7 @@ async function getRetentionStats (req: express.Request, res: express.Response) {}async function getTimeseriesStats (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoWithRightsconst metric = req.params.metric as VideoStatsTimeserieMetricconst query = req.query as VideoStatsTimeserieQuerydiff --git a/server/core/controllers/api/videos/storyboard.ts b/server/core/controllers/api/videos/storyboard.tsindex 92e5801419..5f4b1c569d 100644--- a/server/core/controllers/api/videos/storyboard.ts+++ b/server/core/controllers/api/videos/storyboard.ts@@ -1,12 +1,13 @@-import express from 'express'import { getVideoWithAttributes } from '@server/helpers/video.js'import { StoryboardModel } from '@server/models/video/storyboard.js'-import { asyncMiddleware, videosGetValidator } from '../../../middlewares/index.js'+import express from 'express'+import { asyncMiddleware, videoGetValidatorFactory } from '../../../middlewares/index.js'const storyboardRouter = express.Router()-storyboardRouter.get('/:id/storyboards',- asyncMiddleware(videosGetValidator),+storyboardRouter.get(+ '/:id/storyboards',+ asyncMiddleware(videoGetValidatorFactory('with-blacklist')),asyncMiddleware(listStoryboards))diff --git a/server/core/controllers/api/videos/studio.ts b/server/core/controllers/api/videos/studio.tsindex 25e1efffe5..0389ed9932 100644--- a/server/core/controllers/api/videos/studio.ts+++ b/server/core/controllers/api/videos/studio.ts@@ -66,7 +66,7 @@ export {async function createEditionTasks (req: express.Request, res: express.Response) {const files = req.files as Express.Multer.File[]const body = req.body as VideoStudioCreateEdition- const video = res.locals.videoAll+ const video = res.locals.videoFullvideo.state = VideoState.TO_EDITawait video.save()diff --git a/server/core/controllers/api/videos/token.ts b/server/core/controllers/api/videos/token.tsindex 7a4260954f..1898ef29eb 100644--- a/server/core/controllers/api/videos/token.ts+++ b/server/core/controllers/api/videos/token.ts@@ -1,13 +1,14 @@import express from 'express'import { VideoTokensManager } from '@server/lib/video-tokens-manager.js'import { VideoPrivacy, VideoToken } from '@peertube/peertube-models'-import { asyncMiddleware, optionalAuthenticate, videoFileTokenValidator, videosCustomGetValidator } from '../../../middlewares/index.js'+import { asyncMiddleware, optionalAuthenticate, videoFileTokenValidator, videoGetValidatorFactory } from '../../../middlewares/index.js'const tokenRouter = express.Router()-tokenRouter.post('/:id/token',+tokenRouter.post(+ '/:id/token',optionalAuthenticate,- asyncMiddleware(videosCustomGetValidator('only-video-and-blacklist')),+ asyncMiddleware(videoGetValidatorFactory('with-blacklist')),videoFileTokenValidator,generateToken)@@ -21,7 +22,7 @@ export {// ---------------------------------------------------------------------------function generateToken (req: express.Request, res: express.Response) {- const video = res.locals.onlyVideo+ const video = res.locals.videoWithBlacklistconst files = video.privacy === VideoPrivacy.PASSWORD_PROTECTED? VideoTokensManager.Instance.createForPasswordProtectedVideo({ videoUUID: video.uuid })diff --git a/server/core/controllers/api/videos/transcoding.ts b/server/core/controllers/api/videos/transcoding.tsindex 496243fc2f..497d78c0e3 100644--- a/server/core/controllers/api/videos/transcoding.ts+++ b/server/core/controllers/api/videos/transcoding.ts@@ -28,7 +28,7 @@ export {// ---------------------------------------------------------------------------async function createTranscoding (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoFulllogger.info('Creating %s transcoding job for %s.', req.body.transcodingType, video.url, lTags())const body: VideoTranscodingCreate = req.bodydiff --git a/server/core/controllers/api/videos/update.ts b/server/core/controllers/api/videos/update.tsindex 914edbf31b..5fc5652cc1 100644--- a/server/core/controllers/api/videos/update.ts+++ b/server/core/controllers/api/videos/update.ts@@ -24,7 +24,7 @@ import { openapiOperationDoc } from '@server/middlewares/doc.js'import { VideoChannelActivityModel } from '@server/models/video/video-channel-activity.js'import { VideoPasswordModel } from '@server/models/video/video-password.js'import { FilteredModelAttributes } from '@server/types/index.js'-import { MVideoFullLight, MVideoThumbnail } from '@server/types/models/index.js'+import { MVideoFull, MVideoThumbnails } from '@server/types/models/index.js'import express from 'express'import { Transaction } from 'sequelize'import { VideoAuditView, auditLoggerFactory, getAuditIdFromRes } from '../../../helpers/audit-logger.js'@@ -63,7 +63,7 @@ export {// ---------------------------------------------------------------------------async function updateVideo (req: express.Request, res: express.Response) {- const videoFromReq = res.locals.videoAll+ const videoFromReq = res.locals.videoFullconst oldVideoAuditView = new VideoAuditView(videoFromReq.toFormattedDetailsJSON())const body: VideoUpdate = req.bodyconst user = res.locals.oauth.token.User@@ -133,7 +133,7 @@ async function updateVideo (req: express.Request, res: express.Response) {await video.setAsRefreshed(t)}- const videoInstanceUpdated = await video.save({ transaction: t }) as MVideoFullLight+ const videoInstanceUpdated = await video.save({ transaction: t }) as MVideoFullif (thumbnails.length !== 0) {await videoInstanceUpdated.replaceAndSaveThumbnails(thumbnails, t)@@ -242,7 +242,7 @@ async function updateVideo (req: express.Request, res: express.Response) {// Return a boolean indicating if the video is considered as "new" for remote instances in the federationasync function updateVideoPrivacy (options: {- videoInstance: MVideoFullLight+ videoInstance: MVideoFullvideoInfoToUpdate: VideoUpdatehadPrivacyForFederation: booleantransaction: Transaction@@ -271,7 +271,7 @@ async function updateVideoPrivacy (options: {return isNewVideoForFederation}-async function updateSchedule (videoInstance: MVideoFullLight, videoInfoToUpdate: VideoUpdate, transaction: Transaction) {+async function updateSchedule (videoInstance: MVideoFull, videoInfoToUpdate: VideoUpdate, transaction: Transaction) {if (videoInfoToUpdate.scheduleUpdate) {const updateAt = new Date(videoInfoToUpdate.scheduleUpdate.updateAt)@@ -297,7 +297,7 @@ async function updateSchedule (videoInstance: MVideoFullLight, videoInfoToUpdate}}-async function buildVideoThumbnailsFromReq (video: MVideoThumbnail, req: express.Request) {+async function buildVideoThumbnailsFromReq (video: MVideoThumbnails, req: express.Request) {const file = getVideoThumbnailFile(req.files)if (!file) return []diff --git a/server/core/controllers/api/videos/view.ts b/server/core/controllers/api/videos/view.tsindex 9d395ae2cd..3c3edfa5dd 100644--- a/server/core/controllers/api/videos/view.ts+++ b/server/core/controllers/api/videos/view.ts@@ -32,7 +32,7 @@ export {// ---------------------------------------------------------------------------async function viewVideo (req: express.Request, res: express.Response) {- const video = res.locals.onlyImmutableVideo+ const video = res.locals.videoImmutableconst body = req.body as VideoViewconst ip = req.ipdiff --git a/server/core/controllers/download.ts b/server/core/controllers/download.tsindex b443ce1827..5867c38b03 100644--- a/server/core/controllers/download.ts+++ b/server/core/controllers/download.ts@@ -15,14 +15,7 @@ import { Hooks } from '@server/lib/plugins/hooks.js'import { VideoDownload } from '@server/lib/video-download.js'import { VideoPathManager } from '@server/lib/video-path-manager.js'import { VideoFileModel } from '@server/models/video/video-file.js'-import {- MStreamingPlaylist,- MStreamingPlaylistVideo,- MUserExport,- MVideo,- MVideoFile,- MVideoFullLight-} from '@server/types/models/index.js'+import { MStreamingPlaylist, MStreamingPlaylistVideo, MUserExport, MVideo, MVideoFile, MVideoFull } from '@server/types/models/index.js'import { MVideoSource } from '@server/types/models/video/video-source.js'import contentDisposition from 'content-disposition'import cors from 'cors'@@ -150,7 +143,7 @@ async function downloadTorrent (req: express.Request, res: express.Response) {// ---------------------------------------------------------------------------async function downloadWebVideoFile (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoFullconst videoFile = getVideoFileFromReq(req, video.VideoFiles)if (!videoFile) {@@ -190,7 +183,7 @@ async function downloadWebVideoFile (req: express.Request, res: express.Response}async function downloadHLSVideoFile (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoFullconst streamingPlaylist = getHLSPlaylist(video)if (!streamingPlaylist) return res.sendStatus(HttpStatusCode.NOT_FOUND_404)@@ -235,7 +228,7 @@ async function downloadHLSVideoFile (req: express.Request, res: express.Response// ---------------------------------------------------------------------------async function downloadGeneratedVideoFile (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+ const video = res.locals.videoFullconst filesToSelect = req.query.videoFileIdsconst videoFiles = video.getAllFiles()@@ -344,7 +337,7 @@ function getVideoFileFromReq (req: express.Request, files: MVideoFile[]) {return files.find(f => f.resolution === resolution)}-function getHLSPlaylist (video: MVideoFullLight) {+function getHLSPlaylist (video: MVideoFull) {const playlist = video.VideoStreamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS)if (!playlist) return undefineddiff --git a/server/core/controllers/feeds/comment-feeds.ts b/server/core/controllers/feeds/comment-feeds.tsindex fafe98c99c..80d621e710 100644--- a/server/core/controllers/feeds/comment-feeds.ts+++ b/server/core/controllers/feeds/comment-feeds.ts@@ -43,7 +43,7 @@ export {async function generateVideoCommentsFeed (req: express.Request, res: express.Response) {const start = 0- const video = res.locals.videoAll+ const video = res.locals.videoWithRightsconst account = res.locals.accountconst videoChannel = res.locals.videoChanneldiff --git a/server/core/controllers/feeds/shared/common-feed-utils.ts b/server/core/controllers/feeds/shared/common-feed-utils.tsindex 1ef927fecc..f1a443591e 100644--- a/server/core/controllers/feeds/shared/common-feed-utils.ts+++ b/server/core/controllers/feeds/shared/common-feed-utils.ts@@ -9,7 +9,7 @@ import { regenerateActorImageFiles } from '@server/lib/local-actor.js'import { ServerConfigManager } from '@server/lib/server-config-manager.js'import { getServerActor } from '@server/models/application/application.js'import { UserModel } from '@server/models/user/user.js'-import { MAccountDefault, MChannelBannerAccountDefault, MChannelDefault, MUser, MVideoFullLight } from '@server/types/models/index.js'+import { MAccountDefault, MChannelBannerAccountDefault, MChannelDefault, MUser, MVideo } from '@server/types/models/index.js'import express from 'express'export async function initFeed (parameters: {@@ -114,7 +114,7 @@ export function sendFeed (feed: Feed, req: express.Request, res: express.Responsexport async function buildFeedMetadata (options: {videoChannel?: MChannelBannerAccountDefaultaccount?: MAccountDefault- video?: MVideoFullLight+ video?: MVideo}) {const { video, videoChannel, account } = optionsdiff --git a/server/core/controllers/feeds/video-podcast-feeds.ts b/server/core/controllers/feeds/video-podcast-feeds.tsindex c84179c883..2092cc64e6 100644--- a/server/core/controllers/feeds/video-podcast-feeds.ts+++ b/server/core/controllers/feeds/video-podcast-feeds.ts@@ -9,7 +9,7 @@ import { InternalEventEmitter } from '@server/lib/internal-event-emitter.js'import { Hooks } from '@server/lib/plugins/hooks.js'import { getVideoFileMimeType } from '@server/lib/video-file.js'import { buildPodcastGroupsCache, cacheRouteFactory, videoFeedsPodcastSetCacheKey } from '@server/middlewares/index.js'-import { MVideo, MVideoCaptionVideo, MVideoFullLight } from '@server/types/models/index.js'+import { MVideo, MVideoCaptionVideo, MVideoFull } from '@server/types/models/index.js'import express from 'express'import { extname } from 'path'import { MIMETYPES, ROUTE_CACHE_LIFETIME, VIDEO_CATEGORIES, WEBSERVER } from '../../initializers/constants.js'@@ -273,7 +273,7 @@ function buildVODWebVideoFile (video: MVideo, videoFile: VideoFile) {}}-function buildVODStreamingPlaylistsIfMissingWebVideoFile (video: MVideoFullLight) {+function buildVODStreamingPlaylistsIfMissingWebVideoFile (video: MVideoFull) {const hls = video.getHLSPlaylist()if (!hls) return []@@ -321,7 +321,7 @@ function buildVODStreamingPlaylistsIfMissingWebVideoFile (video: MVideoFullLight]}-function buildLiveStreamingPlaylists (video: MVideoFullLight) {+function buildLiveStreamingPlaylists (video: MVideoFull) {const hls = video.getHLSPlaylist()return [diff --git a/server/core/controllers/object-storage-proxy.ts b/server/core/controllers/object-storage-proxy.tsindex ec879adeb3..7ae4537c4a 100644--- a/server/core/controllers/object-storage-proxy.ts+++ b/server/core/controllers/object-storage-proxy.ts@@ -44,7 +44,7 @@ function proxifyWebVideoController (req: express.Request, res: express.Response)}function proxifyHLSController (req: express.Request, res: express.Response) {- const video = res.locals.onlyVideo+ const video = res.locals.videoWithBlacklistconst filename = req.params.filenameconst reinjectVideoFileToken = filename.endsWith('.m3u8') && doReinjectVideoFileToken(req)diff --git a/server/core/controllers/services.ts b/server/core/controllers/services.tsindex dc1e46f822..c5ade20d1a 100644--- a/server/core/controllers/services.ts+++ b/server/core/controllers/services.ts@@ -5,6 +5,7 @@ import { getOrCreateAPActor } from '@server/lib/activitypub/actors/get.js'import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors/webfinger.js'import { AccountModel } from '@server/models/account/account.js'import { VideoChannelModel } from '@server/models/video/video-channel.js'+import { VideoModel } from '@server/models/video/video.js'import { MChannelSummary, MThumbnail } from '@server/types/models/index.js'import cors from 'cors'import express from 'express'@@ -19,7 +20,7 @@ servicesRouter.use(cors(),apiRateLimiter,asyncMiddleware(oembedValidator),- generateOEmbed+ asyncMiddleware(generateOEmbed))// TODO: deprecated, remove in PeerTube 8.1@@ -44,8 +45,11 @@ export {// ----------------------------------------------------------------------------function generateOEmbed (req: express.Request, res: express.Response) {- if (res.locals.videoAll) return generateVideoOEmbed(req, res)+async function generateOEmbed (req: express.Request, res: express.Response) {+ if (res.locals.videoWithRights) {+ await generateVideoOEmbed(req, res)+ return+ }return generatePlaylistOEmbed(req, res)}@@ -64,14 +68,15 @@ function generatePlaylistOEmbed (req: express.Request, res: express.Response) {return res.json(json)}-function generateVideoOEmbed (req: express.Request, res: express.Response) {- const video = res.locals.videoAll+async function generateVideoOEmbed (req: express.Request, res: express.Response) {+ const video = res.locals.videoWithRights+ const videoWithThumbnails = await VideoModel.loadWithThumbnails(video.id)const json = buildOEmbed({channel: video.VideoChannel,title: video.name,embedPath: video.getEmbedStaticPath() + buildPlayerURLQuery(req.query.url),- thumbnail: video.getBestThumbnail('16:9', 1280),+ thumbnail: videoWithThumbnails.getBestThumbnail('16:9', 1280),req})diff --git a/server/core/helpers/video.ts b/server/core/helpers/video.tsindex 99af095ab7..9dbea3c3da 100644--- a/server/core/helpers/video.ts+++ b/server/core/helpers/video.ts@@ -11,7 +11,7 @@ export function getVideoThumbnailFile (files: express.UploadFiles): Express.Mult}export function getVideoWithAttributes (res: express.Response) {- return res.locals.videoAPI || res.locals.videoAll || res.locals.onlyVideo+ return res.locals.videoAPI || res.locals.videoFull || res.locals.videoWithBlacklist || res.locals.videoWithRights}export function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) {diff --git a/server/core/lib/activitypub/playlists/create-update.ts b/server/core/lib/activitypub/playlists/create-update.tsindex 0f72bf89b5..9595274091 100644--- a/server/core/lib/activitypub/playlists/create-update.ts+++ b/server/core/lib/activitypub/playlists/create-update.ts@@ -177,7 +177,7 @@ async function buildElementsDBAttributes (elementUrls: string[], playlist: MVidetry {const { elementObject } = await fetchRemotePlaylistElement(elementUrl)- const { video } = await getOrCreateAPVideo({ videoObject: { id: elementObject.url }, fetchType: 'only-video-and-blacklist' })+ const { video } = await getOrCreateAPVideo({ videoObject: { id: elementObject.url }, fetchType: 'with-blacklist' })elementsToCreate.push(playlistElementObjectToDBAttributes(elementObject, playlist, video))} catch (err) {diff --git a/server/core/lib/activitypub/process/process-dislike.ts b/server/core/lib/activitypub/process/process-dislike.tsindex 78ac57c65f..e3e08ad659 100644--- a/server/core/lib/activitypub/process/process-dislike.ts+++ b/server/core/lib/activitypub/process/process-dislike.ts@@ -27,7 +27,7 @@ async function processDislike (activity: ActivityDislike, byActor: MActorSignatuif (!byAccount) throw new Error('Cannot create dislike with the non account actor ' + byActor.url)- const { video: onlyVideo } = await maybeGetOrCreateAPVideo({ videoObject: videoUrl, fetchType: 'only-video-and-blacklist' })+ const { video: onlyVideo } = await maybeGetOrCreateAPVideo({ videoObject: videoUrl, fetchType: 'with-blacklist' })if (!onlyVideo?.isLocal()) returnif (!canVideoBeFederated(onlyVideo)) {diff --git a/server/core/lib/activitypub/process/process-like.ts b/server/core/lib/activitypub/process/process-like.tsindex 1053ebaa60..e6538876c6 100644--- a/server/core/lib/activitypub/process/process-like.ts+++ b/server/core/lib/activitypub/process/process-like.ts@@ -29,7 +29,7 @@ async function processLikeVideo (byActor: MActorSignature, activity: ActivityLikconst byAccount = byActor.Accountif (!byAccount) throw new Error('Cannot create like with the non account actor ' + byActor.url)- const { video: onlyVideo } = await maybeGetOrCreateAPVideo({ videoObject: videoUrl, fetchType: 'only-video-and-blacklist' })+ const { video: onlyVideo } = await maybeGetOrCreateAPVideo({ videoObject: videoUrl, fetchType: 'with-blacklist' })if (!onlyVideo?.isLocal()) returnif (!canVideoBeFederated(onlyVideo)) {diff --git a/server/core/lib/activitypub/process/process-update.ts b/server/core/lib/activitypub/process/process-update.tsindex d112904209..9fef91e5bc 100644--- a/server/core/lib/activitypub/process/process-update.ts+++ b/server/core/lib/activitypub/process/process-update.ts@@ -80,7 +80,7 @@ async function processUpdateVideo (activity: ActivityUpdate<VideoObject | stringconst { video, created } = await getOrCreateAPVideo({videoObject: videoObject.id,allowRefresh: false,- fetchType: 'all'+ fetchType: 'full'})// We did not have this video, it has been created so no need to updateif (created) returndiff --git a/server/core/lib/activitypub/process/process-view.ts b/server/core/lib/activitypub/process/process-view.tsindex c1f61196a4..338114ecc3 100644--- a/server/core/lib/activitypub/process/process-view.ts+++ b/server/core/lib/activitypub/process/process-view.ts@@ -24,7 +24,7 @@ async function processCreateView (activity: ActivityView, byActor: MActorSignatuconst { video } = await getOrCreateAPVideo({videoObject,- fetchType: 'only-video-and-blacklist',+ fetchType: 'with-blacklist',allowRefresh: false})diff --git a/server/core/lib/activitypub/send/send-update.ts b/server/core/lib/activitypub/send/send-update.tsindex 738cec8bcd..809134cafd 100644--- a/server/core/lib/activitypub/send/send-update.ts+++ b/server/core/lib/activitypub/send/send-update.ts@@ -13,7 +13,7 @@ import {MActorLight,MChannelDefault,MVideoAPLight,- MVideoFullLight,+ MVideoFull,MVideoPlaylistFull,MVideoRedundancyVideo} from '../../../types/models/index.js'@@ -122,7 +122,7 @@ export async function sendUpdateVideoPlaylist (videoPlaylist: MVideoPlaylistFull})}-export async function sendUpdateVideoPlayerSettings (video: MVideoFullLight, settings: MPlayerSetting, transaction: Transaction) {+export async function sendUpdateVideoPlayerSettings (video: MVideoFull, settings: MPlayerSetting, transaction: Transaction) {if (!canVideoBeFederated(video, false)) returnconst byActor = video.VideoChannel.Account.Actordiff --git a/server/core/lib/activitypub/video-rates.ts b/server/core/lib/activitypub/video-rates.tsindex 1e3a99c5c6..c9b1884bdf 100644--- a/server/core/lib/activitypub/video-rates.ts+++ b/server/core/lib/activitypub/video-rates.ts@@ -1,6 +1,6 @@import { Transaction } from 'sequelize'import { VideoRateType } from '@peertube/peertube-models'-import { MAccountActor, MActorUrl, MVideoAccountLight, MVideoFullLight, MVideoId } from '../../types/models/index.js'+import { MAccountActor, MActorUrl, MVideoAccountLight, MVideoFull, MVideoId } from '../../types/models/index.js'import { sendLike, sendUndoDislike, sendUndoLike } from './send/index.js'import { sendDislike } from './send/send-dislike.js'import { getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlByLocalActor } from './url.js'@@ -8,7 +8,7 @@ import { federateVideoIfNeeded } from './videos/index.js'async function sendVideoRateChange (account: MAccountActor,- video: MVideoFullLight,+ video: MVideoFull,likes: number,dislikes: number,t: Transactiondiff --git a/server/core/lib/activitypub/videos/get.ts b/server/core/lib/activitypub/videos/get.tsindex 13d697f2c6..e80ec7067a 100644--- a/server/core/lib/activitypub/videos/get.ts+++ b/server/core/lib/activitypub/videos/get.ts@@ -2,12 +2,7 @@ import { APObjectId } from '@peertube/peertube-models'import { retryTransactionWrapper } from '@server/helpers/database-utils.js'import { logger } from '@server/helpers/logger.js'import { loadVideoByUrl } from '@server/lib/model-loaders/index.js'-import {- MVideoAccountLightBlacklistAllFiles,- MVideoImmutable,- MVideoThumbnail,- MVideoThumbnailBlacklist-} from '@server/types/models/index.js'+import { MVideoAccountLightBlacklistAllFiles, MVideoImmutable, MVideoThumbnails, MVideoWithBlacklist } from '@server/types/models/index.js'import { getAPId } from '../activity.js'import { refreshVideoIfNeeded, scheduleVideoRefreshIfNeeded } from './refresh.js'import { APVideoCreator, fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared/index.js'@@ -21,21 +16,21 @@ type GetVideoResult<T> = Promise<{type GetVideoParamAll = {videoObject: APObjectIdsyncParam?: SyncParam- fetchType?: 'all'+ fetchType?: 'full'allowRefresh?: boolean}type GetVideoParamImmutable = {videoObject: APObjectIdsyncParam?: SyncParam- fetchType: 'unsafe-only-immutable-attributes'+ fetchType: 'unsafe-immutable-only'allowRefresh: false}type GetVideoParamOther = {videoObject: APObjectIdsyncParam?: SyncParam- fetchType?: 'all' | 'only-video-and-blacklist'+ fetchType?: 'full' | 'with-blacklist'allowRefresh?: boolean}@@ -43,13 +38,13 @@ export function getOrCreateAPVideo (options: GetVideoParamAll): GetVideoResult<Mexport function getOrCreateAPVideo (options: GetVideoParamImmutable): GetVideoResult<MVideoImmutable>export function getOrCreateAPVideo (options: GetVideoParamOther-): GetVideoResult<MVideoAccountLightBlacklistAllFiles | MVideoThumbnailBlacklist>+): GetVideoResult<MVideoAccountLightBlacklistAllFiles | MVideoWithBlacklist>export async function getOrCreateAPVideo (options: GetVideoParamAll | GetVideoParamImmutable | GetVideoParamOther-): GetVideoResult<MVideoAccountLightBlacklistAllFiles | MVideoThumbnailBlacklist | MVideoImmutable> {+): GetVideoResult<MVideoAccountLightBlacklistAllFiles | MVideoWithBlacklist | MVideoImmutable> {// Default paramsconst syncParam = options.syncParam || { rates: true, shares: true, comments: true, refreshVideo: false }- const fetchType = options.fetchType || 'all'+ const fetchType = options.fetchType || 'full'const allowRefresh = options.allowRefresh !== false// Get video url@@ -58,7 +53,7 @@ export async function getOrCreateAPVideo (if (videoFromDatabase) {// We know that allowRefresh === false on `unsafe-only-immutable-attributes` fetch type because of type definitions- let video = videoFromDatabase as MVideoThumbnail+ let video = videoFromDatabase as MVideoThumbnailsif (allowRefresh === true && video.isOutdated()) {if (syncParam.refreshVideo === true) {@@ -79,7 +74,7 @@ export async function getOrCreateAPVideo (if (!videoObject) throw new Error('Cannot fetch remote video with url: ' + videoUrl)// videoUrl is just an alias/redirection, so process object id instead- if (videoObject.id !== videoUrl) return getOrCreateAPVideo({ ...options, fetchType: 'all', videoObject })+ if (videoObject.id !== videoUrl) return getOrCreateAPVideo({ ...options, fetchType: 'full', videoObject })try {const creator = new APVideoCreator(videoObject)@@ -105,7 +100,7 @@ export function maybeGetOrCreateAPVideo (options: GetVideoParamAll): GetVideoResexport function maybeGetOrCreateAPVideo (options: GetVideoParamImmutable): GetVideoResult<MVideoImmutable>export function maybeGetOrCreateAPVideo (options: GetVideoParamOther-): GetVideoResult<MVideoAccountLightBlacklistAllFiles | MVideoThumbnailBlacklist>+): GetVideoResult<MVideoAccountLightBlacklistAllFiles | MVideoWithBlacklist>export async function maybeGetOrCreateAPVideo (options: GetVideoParamAll | GetVideoParamImmutable | GetVideoParamOther) {try {const result = await getOrCreateAPVideo(options as any)diff --git a/server/core/lib/activitypub/videos/refresh.ts b/server/core/lib/activitypub/videos/refresh.tsindex e7e3ec012a..edf46dbb76 100644--- a/server/core/lib/activitypub/videos/refresh.ts+++ b/server/core/lib/activitypub/videos/refresh.ts@@ -4,7 +4,7 @@ import { PeerTubeRequestError } from '@server/helpers/requests.js'import { JobQueue } from '@server/lib/job-queue/job-queue.js'import { VideoLoadByUrlType } from '@server/lib/model-loaders/index.js'import { VideoModel } from '@server/models/video/video.js'-import { MVideo, MVideoFullLight, MVideoThumbnail } from '@server/types/models/index.js'+import { MVideo, MVideoFull, MVideoThumbnails } from '@server/types/models/index.js'import { ActorFollowHealthCache } from '../../actor-follow-health-cache.js'import { fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared/index.js'import { APVideoUpdater } from './updater.js'@@ -20,15 +20,15 @@ export function scheduleVideoRefreshIfNeeded (video: MVideo) {}export async function refreshVideoIfNeeded (options: {- video: MVideoThumbnail+ video: MVideoThumbnailsfetchedType: VideoLoadByUrlTypesyncParam: SyncParam-}): Promise<MVideoThumbnail> {+}): Promise<MVideoThumbnails> {if (!options.video.isOutdated()) return options.video// We need more attributes if the argument video was fetched with not enough joints- const video = options.fetchedType === 'all'- ? options.video as MVideoFullLight+ const video = options.fetchedType === 'full'+ ? options.video as MVideoFull: await VideoModel.loadByUrlAndPopulateAccountAndFiles(options.video.url)const lTags = loggerTagsFactory('ap', 'video', 'refresh', video.uuid, video.url)diff --git a/server/core/lib/activitypub/videos/shared/abstract-builder.ts b/server/core/lib/activitypub/videos/shared/abstract-builder.tsindex 2d355513c5..4946f1b32f 100644--- a/server/core/lib/activitypub/videos/shared/abstract-builder.ts+++ b/server/core/lib/activitypub/videos/shared/abstract-builder.ts@@ -21,8 +21,8 @@ import {MVideo,MVideoCaption,MVideoFile,- MVideoFullLight,- MVideoThumbnail+ MVideoFull,+ MVideoThumbnails} from '@server/types/models/index.js'import { CreationAttributes, Transaction } from 'sequelize'import { fetchAP } from '../../activity.js'@@ -56,7 +56,7 @@ export abstract class APVideoAbstractBuilder {return getOrCreateAPActor(channel.id, 'all')}- protected async setThumbnails (video: MVideoThumbnail, t?: Transaction) {+ protected async setThumbnails (video: MVideoThumbnails, t?: Transaction) {const icons = this.videoObject.iconif (icons.length === 0) {logger.warn('Cannot find thumbnails in video object', { object: this.videoObject, ...this.lTags() })@@ -74,17 +74,17 @@ export abstract class APVideoAbstractBuilder {await video.replaceAndSaveThumbnails(thumbnails, t)}- protected async setTags (video: MVideoFullLight, t: Transaction) {+ protected async setTags (video: MVideoFull, t: Transaction) {const tags = getTagsFromObject(this.videoObject)await setVideoTags({ video, tags, transaction: t })}- protected async setTrackers (video: MVideoFullLight, t: Transaction) {+ protected async setTrackers (video: MVideoFull, t: Transaction) {const trackers = getTrackerUrls(this.videoObject, video)await setVideoTrackers({ video, trackers, transaction: t })}- protected async insertOrReplaceCaptions (video: MVideoFullLight, t: Transaction) {+ protected async insertOrReplaceCaptions (video: MVideoFull, t: Transaction) {const existingCaptions = await VideoCaptionModel.listVideoCaptions(video.id, t)let captionsToCreate = getCaptionAttributesFromObject(video, this.videoObject)@@ -109,7 +109,7 @@ export abstract class APVideoAbstractBuilder {}}- protected async insertOrReplaceStoryboard (video: MVideoFullLight, t: Transaction) {+ protected async insertOrReplaceStoryboard (video: MVideoFull, t: Transaction) {const storyboardAttributes = getStoryboardAttributeFromObject(video, this.videoObject)const existingStoryboard = await StoryboardModel.loadByVideo(video.id, t)@@ -122,7 +122,7 @@ export abstract class APVideoAbstractBuilder {}}- protected async insertOrReplaceLive (video: MVideoFullLight, transaction: Transaction) {+ protected async insertOrReplaceLive (video: MVideoFull, transaction: Transaction) {const attributes = getLiveAttributesFromObject(video, this.videoObject)const [ videoLive ] = await VideoLiveModel.upsert(attributes, { transaction, returning: true })@@ -136,7 +136,7 @@ export abstract class APVideoAbstractBuilder {}}- protected async setWebVideoFiles (video: MVideoFullLight, t: Transaction) {+ protected async setWebVideoFiles (video: MVideoFull, t: Transaction) {const oldFiles = video.VideoFiles || []const newVideoFiles = getFileAttributesFromUrl(video, this.videoObject.url, oldFiles).map(a => new VideoFileModel(a))@@ -149,7 +149,7 @@ export abstract class APVideoAbstractBuilder {video.VideoFiles = await Promise.all(upsertTasks)}- protected async updateChapters (video: MVideoFullLight) {+ protected async updateChapters (video: MVideoFull) {if (!this.videoObject.hasParts || typeof this.videoObject.hasParts !== 'string') returnconst { body } = await fetchAP<VideoChaptersObject>(this.videoObject.hasParts)@@ -169,7 +169,7 @@ export abstract class APVideoAbstractBuilder {})}- protected async upsertPlayerSettings (video: MVideoFullLight) {+ protected async upsertPlayerSettings (video: MVideoFull) {if (typeof this.videoObject.playerSettings !== 'string') returnawait upsertAPPlayerSettings({@@ -180,7 +180,7 @@ export abstract class APVideoAbstractBuilder {})}- protected async setStreamingPlaylists (video: MVideoFullLight, t: Transaction) {+ protected async setStreamingPlaylists (video: MVideoFull, t: Transaction) {const streamingPlaylistAttributes = getStreamingPlaylistAttributesFromObject(video, this.videoObject)const newStreamingPlaylists = streamingPlaylistAttributes.map(a => new VideoStreamingPlaylistModel(a))diff --git a/server/core/lib/activitypub/videos/shared/creator.ts b/server/core/lib/activitypub/videos/shared/creator.tsindex b31c281514..cebb4840fc 100644--- a/server/core/lib/activitypub/videos/shared/creator.ts+++ b/server/core/lib/activitypub/videos/shared/creator.ts@@ -4,7 +4,7 @@ import { sequelizeTypescript } from '@server/initializers/database.js'import { Hooks } from '@server/lib/plugins/hooks.js'import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist.js'import { VideoModel } from '@server/models/video/video.js'-import { MVideoFullLight, MVideoThumbnail } from '@server/types/models/index.js'+import { MVideoFull, MVideoThumbnails } from '@server/types/models/index.js'import { APVideoAbstractBuilder } from './abstract-builder.js'import { getVideoAttributesFromObject } from './object-to-model-attributes.js'@@ -25,10 +25,10 @@ export class APVideoCreator extends APVideoAbstractBuilder {channel.Actor = channelActorconst videoData = getVideoAttributesFromObject(channel, this.videoObject, this.videoObject.to)- const video = VideoModel.build({ ...videoData, likes: 0, dislikes: 0 }) as MVideoThumbnail+ const video = VideoModel.build({ ...videoData, likes: 0, dislikes: 0 }) as MVideoThumbnailsconst { autoBlacklisted, videoCreated } = await sequelizeTypescript.transaction(async t => {- const videoCreated = await video.save({ transaction: t }) as MVideoFullLight+ const videoCreated = await video.save({ transaction: t }) as MVideoFullvideoCreated.VideoChannel = channelawait this.setThumbnails(videoCreated, t)diff --git a/server/core/lib/activitypub/videos/updater.ts b/server/core/lib/activitypub/videos/updater.tsindex aa2f300f0c..f17115bb20 100644--- a/server/core/lib/activitypub/videos/updater.ts+++ b/server/core/lib/activitypub/videos/updater.ts@@ -11,7 +11,7 @@ import {MChannelAccountLight,MChannelId,MVideoAccountLightBlacklistAllFiles,- MVideoFullLight+ MVideoFull} from '@server/types/models/index.js'import { Transaction } from 'sequelize'import { haveActorsSameRemoteHost } from '../actors/check-actor.js'@@ -150,18 +150,18 @@ export class APVideoUpdater extends APVideoAbstractBuilder {// Ensures we update the updatedAt attribute, even if main attributes did not changethis.video.changed('updatedAt', true)- return this.video.save({ transaction }) as Promise<MVideoFullLight>+ return this.video.save({ transaction }) as Promise<MVideoFull>}- private async setCaptions (videoUpdated: MVideoFullLight, t: Transaction) {+ private async setCaptions (videoUpdated: MVideoFull, t: Transaction) {await this.insertOrReplaceCaptions(videoUpdated, t)}- private async setStoryboard (videoUpdated: MVideoFullLight, t: Transaction) {+ private async setStoryboard (videoUpdated: MVideoFull, t: Transaction) {await this.insertOrReplaceStoryboard(videoUpdated, t)}- private async setOrDeleteLive (videoUpdated: MVideoFullLight, transaction?: Transaction) {+ private async setOrDeleteLive (videoUpdated: MVideoFull, transaction?: Transaction) {if (!this.video.isLive) returnif (this.video.isLive) return this.insertOrReplaceLive(videoUpdated, transaction)diff --git a/server/core/lib/job-queue/handlers/activitypub-http-fetcher.ts b/server/core/lib/job-queue/handlers/activitypub-http-fetcher.tsindex 2826f100b9..7cfdccbc72 100644--- a/server/core/lib/job-queue/handlers/activitypub-http-fetcher.ts+++ b/server/core/lib/job-queue/handlers/activitypub-http-fetcher.ts@@ -1,24 +1,24 @@-import { Job } from 'bullmq'import { ActivitypubHttpFetcherPayload, FetchType } from '@peertube/peertube-models'+import { AccountModel } from '@server/models/account/account.js'+import { Job } from 'bullmq'import { logger } from '../../../helpers/logger.js'-import { VideoModel } from '../../../models/video/video.js'import { VideoCommentModel } from '../../../models/video/video-comment.js'import { VideoShareModel } from '../../../models/video/video-share.js'-import { MAccountDefault, MVideoFullLight } from '../../../types/models/index.js'+import { VideoModel } from '../../../models/video/video.js'+import { MAccountDefault, MVideo } from '../../../types/models/index.js'import { crawlCollectionPage } from '../../activitypub/crawl.js'import { createAccountPlaylists } from '../../activitypub/playlists/index.js'import { processActivities } from '../../activitypub/process/index.js'import { addVideoShares } from '../../activitypub/share.js'import { addVideoComments } from '../../activitypub/video-comments.js'-import { AccountModel } from '@server/models/account/account.js'async function processActivityPubHttpFetcher (job: Job) {logger.info('Processing ActivityPub fetcher in job %s.', job.id)const payload = job.data as ActivitypubHttpFetcherPayload- let video: MVideoFullLight- if (payload.videoId) video = await VideoModel.loadFull(payload.videoId)+ let video: MVideo+ if (payload.videoId) video = await VideoModel.load(payload.videoId)let account: MAccountDefaultif (payload.accountId) account = await AccountModel.load(payload.accountId)diff --git a/server/core/lib/job-queue/handlers/activitypub-refresher.ts b/server/core/lib/job-queue/handlers/activitypub-refresher.tsindex 5e85f4b4b6..c009074885 100644--- a/server/core/lib/job-queue/handlers/activitypub-refresher.ts+++ b/server/core/lib/job-queue/handlers/activitypub-refresher.ts@@ -27,7 +27,7 @@ export {// ---------------------------------------------------------------------------async function refreshVideo (videoUrl: string) {- const fetchType = 'all'+ const fetchType = 'full'const syncParam = { rates: true, shares: true, comments: true }const videoFromDatabase = await loadVideoByUrl(videoUrl, fetchType)diff --git a/server/core/lib/job-queue/handlers/notify.ts b/server/core/lib/job-queue/handlers/notify.tsindex 3583d6567b..5a29104293 100644--- a/server/core/lib/job-queue/handlers/notify.ts+++ b/server/core/lib/job-queue/handlers/notify.ts@@ -20,7 +20,7 @@ export {// ---------------------------------------------------------------------------async function doNotifyNewVideo (payload: NotifyPayload & { action: 'new-video' }) {- const refreshedVideo = await VideoModel.loadFull(payload.videoUUID)+ const refreshedVideo = await VideoModel.loadWithRights(payload.videoUUID)if (!refreshedVideo) returnNotifier.Instance.notifyOnNewVideoOrLiveIfNeeded(refreshedVideo)diff --git a/server/core/lib/job-queue/handlers/video-file-import.ts b/server/core/lib/job-queue/handlers/video-file-import.tsindex 7c39ca4152..fcda0b0d29 100644--- a/server/core/lib/job-queue/handlers/video-file-import.ts+++ b/server/core/lib/job-queue/handlers/video-file-import.ts@@ -6,7 +6,7 @@ import { CONFIG } from '@server/initializers/config.js'import { federateVideoIfNeeded } from '@server/lib/activitypub/videos/index.js'import { VideoPathManager } from '@server/lib/video-path-manager.js'import { VideoModel } from '@server/models/video/video.js'-import { MVideoFullLight } from '@server/types/models/index.js'+import { MVideoFull } from '@server/types/models/index.js'import { getVideoStreamDimensionsInfo } from '@peertube/peertube-ffmpeg'import { logger } from '../../../helpers/logger.js'import { JobQueue } from '../job-queue.js'@@ -52,7 +52,7 @@ export {// ----------------------------------------------------------------------------async function updateVideoFile (video: MVideoFullLight, inputFilePath: string) {+async function updateVideoFile (video: MVideoFull, inputFilePath: string) {const { resolution } = await getVideoStreamDimensionsInfo(inputFilePath)const currentVideoFile = video.VideoFiles.find(videoFile => videoFile.resolution === resolution)diff --git a/server/core/lib/job-queue/handlers/video-import.ts b/server/core/lib/job-queue/handlers/video-import.tsindex ee77bdba38..7270f3d8d6 100644--- a/server/core/lib/job-queue/handlers/video-import.ts+++ b/server/core/lib/job-queue/handlers/video-import.ts@@ -28,7 +28,7 @@ import { VideoPathManager } from '@server/lib/video-path-manager.js'import { buildNextVideoState } from '@server/lib/video-state.js'import { createTorrentAndSetInfoHash, downloadWebTorrentVideo } from '@server/lib/webtorrent.js'import { VideoCaptionModel } from '@server/models/video/video-caption.js'-import { MUserId, MVideoFile, MVideoFullLight } from '@server/types/models/index.js'+import { MUserId, MVideoFile, MVideoFull } from '@server/types/models/index.js'import { MVideoImport, MVideoImportDefault, MVideoImportDefaultFiles, MVideoImportVideo } from '@server/types/models/video/video-import.js'import { Job } from 'bullmq'import { FfprobeData } from 'fluent-ffmpeg'@@ -288,7 +288,7 @@ async function generateThumbnails (options: {async function afterImportSuccess (options: {videoImport: MVideoImport- video: MVideoFullLight+ video: MVideoFullvideoFile: MVideoFileuser: MUserIddiff --git a/server/core/lib/job-queue/handlers/video-live-ending.ts b/server/core/lib/job-queue/handlers/video-live-ending.tsindex 25046f336d..27eccb2be0 100644--- a/server/core/lib/job-queue/handlers/video-live-ending.ts+++ b/server/core/lib/job-queue/handlers/video-live-ending.ts@@ -38,9 +38,8 @@ import {MVideoLive,MVideoLiveSession,MVideoTag,- MVideoThumbnail,- MVideoWithAllFiles,- MVideoWithFileThumbnail+ MVideoThumbnails,+ MVideoWithAllFiles} from '@server/types/models/index.js'import { Job } from 'bullmq'import { pathExists, remove } from 'fs-extra/esm'@@ -59,7 +58,7 @@ export async function processVideoLiveEnding (job: Job) {logger.warn('Video live %d does not exist anymore. Cannot process live ending.', payload.videoId, lTags())}- const video = await VideoModel.load(payload.videoId)+ const video = await VideoModel.loadWithThumbnails(payload.videoId)const live = await VideoLiveModel.loadByVideoId(payload.videoId)const liveSession = await VideoLiveSessionModel.load(payload.liveSessionId)@@ -121,7 +120,7 @@ export async function processVideoLiveEnding (job: Job) {// ---------------------------------------------------------------------------async function saveReplayToExternalVideo (options: {- liveVideo: MVideoThumbnail+ liveVideo: MVideoThumbnailsliveSession: MVideoLiveSessionpublishedAt: stringreplayDirectory: string@@ -218,8 +217,8 @@ async function saveReplayToExternalVideo (options: {}async function copyOrRegenerateThumbnails (options: {- liveVideo: MVideoThumbnail- replayVideo: MVideoWithFileThumbnail+ liveVideo: MVideoThumbnails+ replayVideo: MVideoWithAllFiles}) {const { liveVideo, replayVideo } = optionsdiff --git a/server/core/lib/job-queue/handlers/video-studio-edition.ts b/server/core/lib/job-queue/handlers/video-studio-edition.tsindex b94db0e1ae..1fa3968d86 100644--- a/server/core/lib/job-queue/handlers/video-studio-edition.ts+++ b/server/core/lib/job-queue/handlers/video-studio-edition.ts@@ -19,7 +19,7 @@ import { VideoPathManager } from '@server/lib/video-path-manager.js'import { approximateIntroOutroAdditionalSize, onVideoStudioEnded, safeCleanupStudioTMPFiles } from '@server/lib/video-studio.js'import { UserModel } from '@server/models/user/user.js'import { VideoModel } from '@server/models/video/video.js'-import { MVideo, MVideoFullLight } from '@server/types/models/index.js'+import { MVideo, MVideoFull } from '@server/types/models/index.js'import { MutexInterface } from 'async-mutex'import { Job } from 'bullmq'import { remove } from 'fs-extra/esm'@@ -192,7 +192,7 @@ function processAddWatermark (options: TaskProcessorOptions<VideoStudioTaskWater// ----------------------------------------------------------------------------async function checkUserQuotaOrThrow (video: MVideoFullLight, payload: VideoStudioEditionPayload) {+async function checkUserQuotaOrThrow (video: MVideoFull, payload: VideoStudioEditionPayload) {const user = await UserModel.loadByVideoId(video.id)const filePathFinder = (i: number) => (payload.tasks[i] as VideoStudioTaskIntroPayload | VideoStudioTaskOutroPayload).options.filediff --git a/server/core/lib/job-queue/handlers/video-transcoding.ts b/server/core/lib/job-queue/handlers/video-transcoding.tsindex 12ae734a66..14e000d688 100644--- a/server/core/lib/job-queue/handlers/video-transcoding.ts+++ b/server/core/lib/job-queue/handlers/video-transcoding.ts@@ -16,12 +16,12 @@ import { VideoPathManager } from '@server/lib/video-path-manager.js'import { moveToFailedTranscodingState } from '@server/lib/video-state.js'import { UserModel } from '@server/models/user/user.js'import { VideoJobInfoModel } from '@server/models/video/video-job-info.js'-import { MUser, MUserId, MVideoFullLight } from '@server/types/models/index.js'+import { MUser, MUserId, MVideoFull } from '@server/types/models/index.js'import { Job } from 'bullmq'import { logger, loggerTagsFactory } from '../../../helpers/logger.js'import { VideoModel } from '../../../models/video/video.js'-type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void>+type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFull, user: MUser) => Promise<void>const handlers: { [id in VideoTranscodingPayload['type']]: HandlerFunction } = {'new-resolution-to-hls': handleHLSJob,@@ -77,7 +77,7 @@ export {// Job handlers// ----------------------------------------------------------------------------async function handleWebVideoMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) {+async function handleWebVideoMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFull, user: MUserId) {logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid), { payload })await mergeAudioVideofile({ video, resolution: payload.resolution, fps: payload.fps, job })@@ -87,7 +87,7 @@ async function handleWebVideoMergeAudioJob (job: Job, payload: MergeAudioTranscoawait onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: payload.canMoveVideoState, video })}-async function handleWebVideoOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {+async function handleWebVideoOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFull, user: MUserId) {logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid), { payload })await optimizeOriginalVideofile({ video, job })@@ -99,7 +99,7 @@ async function handleWebVideoOptimizeJob (job: Job, payload: OptimizeTranscoding// ----------------------------------------------------------------------------async function handleNewWebVideoResolutionJob (job: Job, payload: NewWebVideoResolutionTranscodingPayload, video: MVideoFullLight) {+async function handleNewWebVideoResolutionJob (job: Job, payload: NewWebVideoResolutionTranscodingPayload, video: MVideoFull) {logger.info('Handling Web Video transcoding job for %s.', video.uuid, lTags(video.uuid), { payload })await transcodeNewWebVideoResolution({ video, resolution: payload.resolution, fps: payload.fps, job })@@ -112,11 +112,11 @@ async function handleNewWebVideoResolutionJob (job: Job, payload: NewWebVideoRes// ----------------------------------------------------------------------------async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, videoArg: MVideoFullLight) {+async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, videoArg: MVideoFull) {logger.info('Handling HLS transcoding job for %s.', videoArg.uuid, lTags(videoArg.uuid), { payload })const inputFileMutexReleaser = await VideoPathManager.Instance.lockFiles(videoArg.uuid)- let video: MVideoFullLight+ let video: MVideoFulltry {video = await VideoModel.loadFull(videoArg.uuid)diff --git a/server/core/lib/local-video-creator.ts b/server/core/lib/local-video-creator.tsindex 7386e07ee2..89b41e4151 100644--- a/server/core/lib/local-video-creator.ts+++ b/server/core/lib/local-video-creator.ts@@ -23,7 +23,7 @@ import { VideoLiveScheduleModel } from '@server/models/video/video-live-scheduleimport { VideoLiveModel } from '@server/models/video/video-live.js'import { VideoPasswordModel } from '@server/models/video/video-password.js'import { VideoModel } from '@server/models/video/video.js'-import { MChannel, MChannelAccountLight, MUserAccountId, MVideoFile, MVideoFullLight } from '@server/types/models/index.js'+import { MChannel, MChannelAccountLight, MUserAccountId, MVideoFile, MVideoFull } from '@server/types/models/index.js'import { FilteredModelAttributes } from '@server/types/sequelize.js'import { FfprobeData } from 'fluent-ffmpeg'import { move } from 'fs-extra/esm'@@ -78,7 +78,7 @@ export class LocalVideoCreator {private readonly channel: MChannelAccountLightprivate readonly videoAttributeResultHook: VideoAttributeHookFilter- private video: MVideoFullLight+ private video: MVideoFullprivate videoFile: MVideoFileprivate videoPath: string@@ -122,7 +122,7 @@ export class LocalVideoCreator {async create () {this.video = new VideoModel(await Hooks.wrapObject(this.buildVideo(this.videoAttributes, this.channel), this.videoAttributeResultHook)- ) as MVideoFullLight+ ) as MVideoFullthis.video.VideoChannel = this.channelthis.video.url = getLocalVideoActivityPubUrl(this.video)diff --git a/server/core/lib/model-loaders/video.ts b/server/core/lib/model-loaders/video.tsindex 6e4626c8b4..1b0df1e680 100644--- a/server/core/lib/model-loaders/video.ts+++ b/server/core/lib/model-loaders/video.ts@@ -3,60 +3,75 @@ import { VideoModel } from '@server/models/video/video.js'import {MVideoAccountLightBlacklistAllFiles,MVideoFormattableDetails,- MVideoFullLight,+ MVideoFull,MVideoId,MVideoImmutable,- MVideoThumbnailBlacklist+ MVideoThumbnails,+ MVideoWithBlacklist,+ MVideoWithRights} from '@server/types/models/index.js'import { getOrCreateAPVideo } from '../activitypub/videos/get.js'-type VideoLoadType = 'for-api' | 'all' | 'only-video-and-blacklist' | 'id' | 'none' | 'unsafe-only-immutable-attributes'+type VideoLoadType =+ | 'for-api'+ | 'full'+ | 'with-blacklist'+ | 'with-thumbnails'+ | 'with-rights'+ | 'id'+ | 'none'+ | 'unsafe-immutable-only'function loadVideo (id: number | string, fetchType: 'for-api', userId?: number): Promise<MVideoFormattableDetails>-function loadVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight>-function loadVideo (id: number | string, fetchType: 'unsafe-only-immutable-attributes'): Promise<MVideoImmutable>-function loadVideo (id: number | string, fetchType: 'only-video-and-blacklist', userId?: number): Promise<MVideoThumbnailBlacklist>+function loadVideo (id: number | string, fetchType: 'full', userId?: number): Promise<MVideoFull>+function loadVideo (id: number | string, fetchType: 'with-blacklist', userId?: number): Promise<MVideoWithBlacklist>+function loadVideo (id: number | string, fetchType: 'with-thumbnails', userId?: number): Promise<MVideoThumbnails>function loadVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise<MVideoId>+function loadVideo (id: number | string, fetchType: 'unsafe-immutable-only'): Promise<MVideoImmutable>+function loadVideo (id: number | string, fetchType: 'with-rights'): Promise<MVideoWithRights>function loadVideo (id: number | string,fetchType: VideoLoadType,userId?: number-): Promise<MVideoFullLight | MVideoThumbnailBlacklist | MVideoId | MVideoImmutable>+): Promise<MVideoFull | MVideoWithBlacklist | MVideoId | MVideoImmutable | MVideoThumbnails | MVideoWithRights>function loadVideo (id: number | string,fetchType: VideoLoadType,userId?: number-): Promise<MVideoFullLight | MVideoThumbnailBlacklist | MVideoId | MVideoImmutable> {-+): Promise<MVideoFull | MVideoWithBlacklist | MVideoId | MVideoImmutable | MVideoThumbnails> {if (fetchType === 'for-api') return VideoModel.loadForGetAPI({ id, userId })- if (fetchType === 'all') return VideoModel.loadFull(id, undefined, userId)+ if (fetchType === 'full') return VideoModel.loadFull(id, undefined, userId)++ if (fetchType === 'unsafe-immutable-only') return VideoModel.loadImmutableAttributes(id)++ if (fetchType === 'with-blacklist') return VideoModel.loadWithBlacklist(id)- if (fetchType === 'unsafe-only-immutable-attributes') return VideoModel.loadImmutableAttributes(id)+ if (fetchType === 'with-thumbnails') return VideoModel.loadWithThumbnails(id)- if (fetchType === 'only-video-and-blacklist') return VideoModel.loadWithBlacklist(id)+ if (fetchType === 'with-rights') return VideoModel.loadWithRights(id)if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id)}-type VideoLoadByUrlType = 'all' | 'only-video-and-blacklist' | 'unsafe-only-immutable-attributes'+type VideoLoadByUrlType = 'full' | 'with-blacklist' | 'unsafe-immutable-only'-function loadVideoByUrl (url: string, fetchType: 'all'): Promise<MVideoAccountLightBlacklistAllFiles>-function loadVideoByUrl (url: string, fetchType: 'unsafe-only-immutable-attributes'): Promise<MVideoImmutable>-function loadVideoByUrl (url: string, fetchType: 'only-video-and-blacklist'): Promise<MVideoThumbnailBlacklist>+function loadVideoByUrl (url: string, fetchType: 'full'): Promise<MVideoAccountLightBlacklistAllFiles>+function loadVideoByUrl (url: string, fetchType: 'unsafe-immutable-only'): Promise<MVideoImmutable>+function loadVideoByUrl (url: string, fetchType: 'with-blacklist'): Promise<MVideoWithBlacklist>function loadVideoByUrl (url: string,fetchType: VideoLoadByUrlType-): Promise<MVideoAccountLightBlacklistAllFiles | MVideoThumbnailBlacklist | MVideoImmutable>+): Promise<MVideoAccountLightBlacklistAllFiles | MVideoWithBlacklist | MVideoImmutable>function loadVideoByUrl (url: string,fetchType: VideoLoadByUrlType-): Promise<MVideoAccountLightBlacklistAllFiles | MVideoThumbnailBlacklist | MVideoImmutable> {- if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccountAndFiles(url)+): Promise<MVideoAccountLightBlacklistAllFiles | MVideoWithBlacklist | MVideoImmutable> {+ if (fetchType === 'full') return VideoModel.loadByUrlAndPopulateAccountAndFiles(url)- if (fetchType === 'unsafe-only-immutable-attributes') return VideoModel.loadByUrlImmutableAttributes(url)+ if (fetchType === 'unsafe-immutable-only') return VideoModel.loadByUrlImmutableAttributes(url)- if (fetchType === 'only-video-and-blacklist') return VideoModel.loadByUrlWithBlacklist(url)+ if (fetchType === 'with-blacklist') return VideoModel.loadByUrlWithBlacklist(url)}async function loadOrCreateVideoIfAllowedForUser (videoUrl: string) {@@ -64,7 +79,7 @@ async function loadOrCreateVideoIfAllowedForUser (videoUrl: string) {try {const res = await getOrCreateAPVideo({videoObject: videoUrl,- fetchType: 'unsafe-only-immutable-attributes',+ fetchType: 'unsafe-immutable-only',allowRefresh: false})@@ -78,7 +93,8 @@ async function loadOrCreateVideoIfAllowedForUser (videoUrl: string) {}export {- loadOrCreateVideoIfAllowedForUser, loadVideo,+ loadOrCreateVideoIfAllowedForUser,+ loadVideo,loadVideoByUrl,type VideoLoadByUrlType,type VideoLoadTypediff --git a/server/core/lib/notifier/notifier.ts b/server/core/lib/notifier/notifier.tsindex e031521300..83112e0c3b 100644--- a/server/core/lib/notifier/notifier.ts+++ b/server/core/lib/notifier/notifier.ts@@ -15,7 +15,8 @@ import {MPlugin,MVideoAccountLight,MVideoCaptionVideo,- MVideoFullLight+ MVideoFull,+ MVideoWithSchedule} from '../../types/models/index.js'import { JobQueue } from '../job-queue/index.js'import { PeerTubeSocket } from '../peertube-socket.js'@@ -97,7 +98,7 @@ class Notifier {.catch(err => logger.error('Cannot notify subscribers of new video %s.', video.url, { err }))}- notifyOnVideoPublishedAfterTranscoding (video: MVideoFullLight): void {+ notifyOnVideoPublishedAfterTranscoding (video: MVideoAccountLight & MVideoWithSchedule): void {const models = this.notificationModels.publicationAfterTranscodinglogger.debug('Notify on published video after transcoding', { video: video.url, ...lTags() })@@ -106,7 +107,7 @@ class Notifier {.catch(err => logger.error('Cannot notify owner that its video %s has been published after transcoding.', video.url, { err }))}- notifyOnVideoPublishedAfterScheduledUpdate (video: MVideoFullLight): void {+ notifyOnVideoPublishedAfterScheduledUpdate (video: MVideoAccountLight & MVideoWithSchedule): void {const models = this.notificationModels.publicationAfterScheduleUpdatelogger.debug('Notify on published video after scheduled update', { video: video.url, ...lTags() })@@ -115,7 +116,7 @@ class Notifier {.catch(err => logger.error('Cannot notify owner that its video %s has been published after scheduled update.', video.url, { err }))}- notifyOnVideoPublishedAfterRemovedFromAutoBlacklist (video: MVideoFullLight): void {+ notifyOnVideoPublishedAfterRemovedFromAutoBlacklist (video: MVideoAccountLight & MVideoWithSchedule): void {const models = this.notificationModels.publicationAfterAutoUnblacklistlogger.debug('Notify on published video after being removed from auto blacklist', { video: video.url, ...lTags() })@@ -171,7 +172,7 @@ class Notifier {.catch(err => logger.error('Cannot notify video owner of new video blacklist of %s.', videoBlacklist.Video.url, { err }))}- notifyOnVideoUnblacklist (video: MVideoFullLight): void {+ notifyOnVideoUnblacklist (video: MVideoAccountLight): void {const models = this.notificationModels.unblacklistlogger.debug('Notify on video unblacklist', { video: video.url, ...lTags() })@@ -277,7 +278,7 @@ class Notifier {.catch(err => logger.error('Cannot notify on new plugin version %s.', plugin.name, { err }))}- notifyOfFinishedVideoStudioEdition (video: MVideoFullLight) {+ notifyOfFinishedVideoStudioEdition (video: MVideoFull) {const models = this.notificationModels.videoStudioEditionFinishedlogger.debug('Notify on finished video studio edition', { video: video.url, ...lTags() })diff --git a/server/core/lib/notifier/shared/blacklist/unblacklist-for-owner.ts b/server/core/lib/notifier/shared/blacklist/unblacklist-for-owner.tsindex 41f94d99f5..a96412c134 100644--- a/server/core/lib/notifier/shared/blacklist/unblacklist-for-owner.ts+++ b/server/core/lib/notifier/shared/blacklist/unblacklist-for-owner.ts@@ -1,14 +1,14 @@+import { UserNotificationType } from '@peertube/peertube-models'+import { tu } from '@server/helpers/i18n.js'import { logger } from '@server/helpers/logger.js'import { CONFIG } from '@server/initializers/config.js'import { WEBSERVER } from '@server/initializers/constants.js'-import { UserModel } from '@server/models/user/user.js'import { UserNotificationModel } from '@server/models/user/user-notification.js'-import { MUserDefault, MUserWithNotificationSetting, MVideoFullLight, UserNotificationModelForApi } from '@server/types/models/index.js'-import { UserNotificationType } from '@peertube/peertube-models'+import { UserModel } from '@server/models/user/user.js'+import { MUserDefault, MUserWithNotificationSetting, MVideoAccountLight, UserNotificationModelForApi } from '@server/types/models/index.js'import { AbstractNotification } from '../common/abstract-notification.js'-import { tu } from '@server/helpers/i18n.js'-export class UnblacklistForOwner extends AbstractNotification<MVideoFullLight> {+export class UnblacklistForOwner extends AbstractNotification<MVideoAccountLight> {private user: MUserDefaultasync prepare () {diff --git a/server/core/lib/notifier/shared/video-publication/abstract-owned-video-publication.ts b/server/core/lib/notifier/shared/video-publication/abstract-owned-video-publication.tsindex 691c1078fb..2cebab7bb1 100644--- a/server/core/lib/notifier/shared/video-publication/abstract-owned-video-publication.ts+++ b/server/core/lib/notifier/shared/video-publication/abstract-owned-video-publication.ts@@ -1,13 +1,19 @@-import { logger } from '@server/helpers/logger.js'+import { UserNotificationType } from '@peertube/peertube-models'import { t } from '@server/helpers/i18n.js'+import { logger } from '@server/helpers/logger.js'import { WEBSERVER } from '@server/initializers/constants.js'-import { UserModel } from '@server/models/user/user.js'import { UserNotificationModel } from '@server/models/user/user-notification.js'-import { MUserDefault, MUserWithNotificationSetting, MVideoFullLight, UserNotificationModelForApi } from '@server/types/models/index.js'-import { UserNotificationType } from '@peertube/peertube-models'+import { UserModel } from '@server/models/user/user.js'+import {+ MUserDefault,+ MUserWithNotificationSetting,+ MVideoWithRights,+ MVideoWithSchedule,+ UserNotificationModelForApi+} from '@server/types/models/index.js'import { AbstractNotification } from '../common/abstract-notification.js'-export abstract class AbstractOwnedVideoPublication extends AbstractNotification<MVideoFullLight> {+export abstract class AbstractOwnedVideoPublication extends AbstractNotification<MVideoWithRights & MVideoWithSchedule> {protected user: MUserDefaultasync prepare () {diff --git a/server/core/lib/notifier/shared/video-publication/studio-edition-finished-for-owner.ts b/server/core/lib/notifier/shared/video-publication/studio-edition-finished-for-owner.tsindex 12b384c84d..b6b2fb5890 100644--- a/server/core/lib/notifier/shared/video-publication/studio-edition-finished-for-owner.ts+++ b/server/core/lib/notifier/shared/video-publication/studio-edition-finished-for-owner.ts@@ -4,10 +4,10 @@ import { logger } from '@server/helpers/logger.js'import { WEBSERVER } from '@server/initializers/constants.js'import { UserNotificationModel } from '@server/models/user/user-notification.js'import { UserModel } from '@server/models/user/user.js'-import { MUserDefault, MUserWithNotificationSetting, MVideoFullLight, UserNotificationModelForApi } from '@server/types/models/index.js'+import { MUserDefault, MUserWithNotificationSetting, MVideoFull, UserNotificationModelForApi } from '@server/types/models/index.js'import { AbstractNotification } from '../common/abstract-notification.js'-export class StudioEditionFinishedForOwner extends AbstractNotification<MVideoFullLight> {+export class StudioEditionFinishedForOwner extends AbstractNotification<MVideoFull> {private user: MUserDefaultasync prepare () {diff --git a/server/core/lib/plugins/plugin-helpers-builder.ts b/server/core/lib/plugins/plugin-helpers-builder.tsindex 05d2c925df..404879f073 100644--- a/server/core/lib/plugins/plugin-helpers-builder.ts+++ b/server/core/lib/plugins/plugin-helpers-builder.ts@@ -85,7 +85,7 @@ function buildVideosHelpers () {},loadByIdOrUUID: (id: number | string) => {- return VideoModel.load(id)+ return VideoModel.loadWithThumbnails(id)},loadByIdOrUUIDWithFiles: (id: number | string) => {diff --git a/server/core/lib/rate.ts b/server/core/lib/rate.tsindex 1e047da5a7..b67f7ce9ef 100644--- a/server/core/lib/rate.ts+++ b/server/core/lib/rate.ts@@ -3,13 +3,13 @@ import { sequelizeTypescript } from '@server/initializers/database.js'import { AccountVideoRateModel } from '@server/models/account/account-video-rate.js'import { AccountModel } from '@server/models/account/account.js'import { getLocalRateUrl, sendVideoRateChange } from './activitypub/video-rates.js'-import { MAccountId, MAccountUrl, MVideoFullLight } from '@server/types/models/index.js'+import { MAccountId, MAccountUrl, MVideoFull } from '@server/types/models/index.js'import { UserVideoRateType } from '@peertube/peertube-models'export async function userRateVideo (options: {rateType: UserVideoRateTypeaccount: MAccountUrl & MAccountId- video: MVideoFullLight+ video: MVideoFull}) {const { account, rateType, video } = optionsdiff --git a/server/core/lib/runners/job-handlers/shared/utils.ts b/server/core/lib/runners/job-handlers/shared/utils.tsindex 102dbdc374..4e76eefe1e 100644--- a/server/core/lib/runners/job-handlers/shared/utils.ts+++ b/server/core/lib/runners/job-handlers/shared/utils.ts@@ -7,11 +7,11 @@ import { logger, LoggerTagsFn } from '@server/helpers/logger.js'import { onTranscodingEnded } from '@server/lib/transcoding/ended-transcoding.js'import { onWebVideoFileTranscoding } from '@server/lib/transcoding/web-transcoding.js'import { VideoModel } from '@server/models/video/video.js'-import { MVideoFullLight } from '@server/types/models/index.js'+import { MVideoFull } from '@server/types/models/index.js'import { MRunnerJob } from '@server/types/models/runners/index.js'export async function onVODWebVideoOrAudioMergeTranscodingJob (options: {- video: MVideoFullLight+ video: MVideoFullvideoFilePath: stringprivatePayload: RunnerJobVODWebVideoTranscodingPrivatePayload | RunnerJobVODAudioMergeTranscodingPrivatePayloadwasAudioFile: booleandiff --git a/server/core/lib/schedulers/videos-redundancy-scheduler.ts b/server/core/lib/schedulers/videos-redundancy-scheduler.tsindex 3a8bf67157..368f334170 100644--- a/server/core/lib/schedulers/videos-redundancy-scheduler.ts+++ b/server/core/lib/schedulers/videos-redundancy-scheduler.ts@@ -304,7 +304,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler {const getVideoOptions = {videoObject: videoUrl,syncParam: { rates: false, shares: false, comments: false, refreshVideo: true },- fetchType: 'all' as 'all'+ fetchType: 'full' as const}const { video } = await getOrCreateAPVideo(getVideoOptions)diff --git a/server/core/lib/thumbnail.ts b/server/core/lib/thumbnail.tsindex 3769bbdfe0..5ea9daa18c 100644--- a/server/core/lib/thumbnail.ts+++ b/server/core/lib/thumbnail.ts@@ -10,7 +10,7 @@ import { generateImageFilename, processImage } from '../helpers/image-utils.js'import { CONFIG } from '../initializers/config.js'import { ASSETS_PATH, MIMETYPES } from '../initializers/constants.js'import { ThumbnailModel } from '../models/video/thumbnail.js'-import { MVideoFile, MVideoThumbnail, MVideoUUID, MVideoWithAllFiles } from '../types/models/index.js'+import { MVideoFile, MVideoThumbnails, MVideoUUID, MVideoWithAllFiles } from '../types/models/index.js'import { MThumbnail } from '../types/models/video/thumbnail.js'import { MVideoPlaylistThumbnail } from '../types/models/video/video-playlist.js'import downloadImage from './image-downloader.js'@@ -97,7 +97,7 @@ export function updateRemotePlaylistThumbnailFromUrl (options: {export async function createLocalVideoThumbnailsFromImage (options: {inputPath: string- video: MVideoThumbnail+ video: MVideoThumbnailsautomaticallyGenerated: booleankeepOriginal?: boolean // default to false}) {@@ -123,7 +123,7 @@ export async function createLocalVideoThumbnailsFromImage (options: {function _createLocalVideoThumbnailFromImage (options: {inputPath: string- video: MVideoThumbnail+ video: MVideoThumbnailsautomaticallyGenerated: booleansize: ImageSizekeepOriginal: boolean@@ -155,7 +155,7 @@ function _createLocalVideoThumbnailFromImage (options: {// Returns thumbnail models sorted by their size (height) in descendent order (biggest first)export function createLocalVideoThumbnailsFromVideo (options: {- video: MVideoThumbnail+ video: MVideoThumbnailsvideoFile: MVideoFileffprobe: FfprobeData}): Promise<MThumbnail[]> {@@ -220,7 +220,7 @@ export function createLocalVideoThumbnailsFromVideo (options: {export function createLocalVideoThumbnailsFromUrl (options: {downloadUrl: string- video: MVideoThumbnail+ video: MVideoThumbnails}) {const { downloadUrl, video } = options@@ -231,7 +231,7 @@ export function createLocalVideoThumbnailsFromUrl (options: {function _createLocalVideoThumbnailFromUrl (options: {downloadUrl: string- video: MVideoThumbnail+ video: MVideoThumbnailssize: ImageSize}) {const { downloadUrl, video, size } = options@@ -250,7 +250,7 @@ function _createLocalVideoThumbnailFromUrl (options: {export function updateRemoteVideoThumbnail (options: {fileUrl: string- video: MVideoThumbnail+ video: MVideoThumbnailssize: ImageSize}) {const { fileUrl, video, size } = options@@ -350,7 +350,7 @@ function buildMetadataFromPlaylist (options: {}function buildMetadataFromVideo (options: {- video: MVideoThumbnail+ video: MVideoThumbnailssize: ImageSizeextension: string}) {diff --git a/server/core/lib/transcoding/create-transcoding-job.ts b/server/core/lib/transcoding/create-transcoding-job.tsindex f2c70c624c..a376d9f63a 100644--- a/server/core/lib/transcoding/create-transcoding-job.ts+++ b/server/core/lib/transcoding/create-transcoding-job.ts@@ -1,9 +1,9 @@import { CONFIG } from '@server/initializers/config.js'-import { MUserId, MVideoFile, MVideoFullLight } from '@server/types/models/index.js'+import { MUserId, MVideoFile, MVideoFull } from '@server/types/models/index.js'import { TranscodingJobQueueBuilder, TranscodingRunnerJobBuilder } from './shared/index.js'export function createOptimizeOrMergeAudioJobs (options: {- video: MVideoFullLight+ video: MVideoFullvideoFile: MVideoFileisNewVideo: booleanuser: MUserId@@ -15,7 +15,7 @@ export function createOptimizeOrMergeAudioJobs (options: {export function createTranscodingJobs (options: {transcodingType: 'hls' | 'web-video'- video: MVideoFullLight+ video: MVideoFullresolutions: number[]isNewVideo: booleanuser: MUserIddiff --git a/server/core/lib/transcoding/shared/job-builders/abstract-job-builder.ts b/server/core/lib/transcoding/shared/job-builders/abstract-job-builder.tsindex ee1a96d188..c311bf46aa 100644--- a/server/core/lib/transcoding/shared/job-builders/abstract-job-builder.ts+++ b/server/core/lib/transcoding/shared/job-builders/abstract-job-builder.ts@@ -4,7 +4,7 @@ import { logger, loggerTagsFactory } from '@server/helpers/logger.js'import { CONFIG } from '@server/initializers/config.js'import { DEFAULT_AUDIO_MERGE_RESOLUTION, DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants.js'import { Hooks } from '@server/lib/plugins/hooks.js'-import { MUserId, MVideoFile, MVideoFullLight } from '@server/types/models/index.js'+import { MUserId, MVideoFile, MVideoFull } from '@server/types/models/index.js'import { buildOriginalFileResolution, computeResolutionsToTranscode } from '../../transcoding-resolutions.js'const lTags = loggerTagsFactory('transcoding')@@ -13,7 +13,7 @@ export type TranscodingPriorityType = 'required' | 'optional'export abstract class AbstractJobBuilder<P extends { transcodingPriority: TranscodingPriorityType }> {async createOptimizeOrMergeAudioJobs (options: {- video: MVideoFullLight+ video: MVideoFullvideoFile: MVideoFileisNewVideo: booleanuser: MUserId@@ -136,7 +136,7 @@ export abstract class AbstractJobBuilder<P extends { transcodingPriority: Transcasync createTranscodingJobs (options: {transcodingType: 'hls' | 'web-video'- video: MVideoFullLight+ video: MVideoFullresolutions: number[]isNewVideo: booleanuser: MUserId | null@@ -213,7 +213,7 @@ export abstract class AbstractJobBuilder<P extends { transcodingPriority: Transc}private async buildLowerResolutionJobPayloads (options: {- video: MVideoFullLight+ video: MVideoFullinputVideoResolution: numberinputVideoFPS: numberinputStreams: VideoFileStreamType[]@@ -315,7 +315,7 @@ export abstract class AbstractJobBuilder<P extends { transcodingPriority: Transc// ---------------------------------------------------------------------------protected abstract createJobs (options: {- video: MVideoFullLight+ video: MVideoFullpayloads: {parent: P@@ -328,7 +328,7 @@ export abstract class AbstractJobBuilder<P extends { transcodingPriority: Transc}): Promise<void>protected abstract buildMergeAudioPayload (options: {- video: MVideoFullLight+ video: MVideoFullinputFile: MVideoFileisNewVideo: booleanresolution: number@@ -339,7 +339,7 @@ export abstract class AbstractJobBuilder<P extends { transcodingPriority: Transc}): Pprotected abstract buildOptimizePayload (options: {- video: MVideoFullLight+ video: MVideoFullisNewVideo: booleaninputFile: MVideoFileresolution: number@@ -350,7 +350,7 @@ export abstract class AbstractJobBuilder<P extends { transcodingPriority: Transc}): Pprotected abstract buildHLSJobPayload (options: {- video: MVideoFullLight+ video: MVideoFullresolution: numberfps: numberisNewVideo: boolean@@ -366,7 +366,7 @@ export abstract class AbstractJobBuilder<P extends { transcodingPriority: Transc}): Pprotected abstract buildWebVideoJobPayload (options: {- video: MVideoFullLight+ video: MVideoFullresolution: numberfps: numberisNewVideo: booleandiff --git a/server/core/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts b/server/core/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.tsindex 4c8bd95281..b32812c502 100644--- a/server/core/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts+++ b/server/core/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts@@ -5,7 +5,7 @@ import {VODHLSTranscodingJobHandler,VODWebVideoTranscodingJobHandler} from '@server/lib/runners/job-handlers/index.js'-import { MUserId, MVideo, MVideoFile, MVideoFullLight } from '@server/types/models/index.js'+import { MUserId, MVideo, MVideoFile, MVideoFull } from '@server/types/models/index.js'import { MRunnerJob } from '@server/types/models/runners/runner-job.js'import { getTranscodingJobPriority } from '../../transcoding-priority.js'import { AbstractJobBuilder, TranscodingPriorityType } from './abstract-job-builder.js'@@ -90,7 +90,7 @@ export class TranscodingRunnerJobBuilder extends AbstractJobBuilder<FullPayload>// ---------------------------------------------------------------------------protected buildHLSJobPayload (options: {- video: MVideoFullLight+ video: MVideoFullresolution: numberfps: numberisNewVideo: boolean@@ -129,7 +129,7 @@ export class TranscodingRunnerJobBuilder extends AbstractJobBuilder<FullPayload>}protected buildWebVideoJobPayload (options: {- video: MVideoFullLight+ video: MVideoFullresolution: numberfps: numberisNewVideo: boolean@@ -159,7 +159,7 @@ export class TranscodingRunnerJobBuilder extends AbstractJobBuilder<FullPayload>}protected buildMergeAudioPayload (options: {- video: MVideoFullLight+ video: MVideoFullinputFile: MVideoFileisNewVideo: booleanfps: number@@ -190,7 +190,7 @@ export class TranscodingRunnerJobBuilder extends AbstractJobBuilder<FullPayload>}protected buildOptimizePayload (options: {- video: MVideoFullLight+ video: MVideoFullinputFile: MVideoFileisNewVideo: booleanfps: numberdiff --git a/server/core/lib/transcoding/web-transcoding.ts b/server/core/lib/transcoding/web-transcoding.tsindex 7500264448..af0683ab76 100644--- a/server/core/lib/transcoding/web-transcoding.ts+++ b/server/core/lib/transcoding/web-transcoding.ts@@ -9,7 +9,7 @@ import { VideoFileStream } from '@peertube/peertube-models'import { computeOutputFPS } from '@server/helpers/ffmpeg/index.js'import { createTorrentAndSetInfoHash } from '@server/lib/webtorrent.js'import { VideoModel } from '@server/models/video/video.js'-import { MVideoFile, MVideoFullLight } from '@server/types/models/index.js'+import { MVideoFile, MVideoFull } from '@server/types/models/index.js'import { Job } from 'bullmq'import { move, remove } from 'fs-extra/esm'import { copyFile } from 'fs/promises'@@ -26,7 +26,7 @@ import { buildOriginalFileResolution } from './transcoding-resolutions.js'// Optimize the original video file and replace it. The resolution is not changed.export async function optimizeOriginalVideofile (options: {- video: MVideoFullLight+ video: MVideoFulljob: Job}) {const { job } = options@@ -77,7 +77,7 @@ export async function optimizeOriginalVideofile (options: {// Transcode the original/old/source video file to a lower resolution compatible with web browsersexport async function transcodeNewWebVideoResolution (options: {- video: MVideoFullLight+ video: MVideoFullresolution: numberfps: numberjob: Job@@ -123,7 +123,7 @@ export async function transcodeNewWebVideoResolution (options: {// Merge an image with an audio file to create a videoexport async function mergeAudioVideofile (options: {- video: MVideoFullLight+ video: MVideoFullresolution: numberfps: numberjob: Job@@ -185,7 +185,7 @@ export async function mergeAudioVideofile (options: {}export async function onWebVideoFileTranscoding (options: {- video: MVideoFullLight+ video: MVideoFullvideoOutputPath: stringwasAudioFile?: boolean // default falsedeleteWebInputVideoFile?: MVideoFilediff --git a/server/core/lib/user-import-export/exporters/videos-exporter.ts b/server/core/lib/user-import-export/exporters/videos-exporter.tsindex f581733f2c..02d387e5b1 100644--- a/server/core/lib/user-import-export/exporters/videos-exporter.ts+++ b/server/core/lib/user-import-export/exporters/videos-exporter.ts@@ -29,7 +29,7 @@ import {MVideoCaptionLanguageUrl,MVideoChapter,MVideoFile,- MVideoFullLight,+ MVideoFull,MVideoLiveWithSettingSchedules,MVideoPassword} from '@server/types/models/index.js'@@ -128,7 +128,7 @@ export class VideosExporter extends AbstractUserExporter<VideoExportJSON> {// ---------------------------------------------------------------------------private exportVideoJSON (options: {- video: MVideoFullLight+ video: MVideoFullcaptions: MVideoCaption[]live: MVideoLiveWithSettingSchedulespasswords: MVideoPassword[]@@ -371,7 +371,7 @@ export class VideosExporter extends AbstractUserExporter<VideoExportJSON> {// ---------------------------------------------------------------------------private async exportVideoFiles (options: {- video: MVideoFullLight+ video: MVideoFullcaptions: MVideoCaption[]}) {const { video, captions } = options@@ -445,7 +445,7 @@ export class VideosExporter extends AbstractUserExporter<VideoExportJSON> {private async generateVideoFileReadStream (options: {videoFile: MVideoFileseparatedAudioFile: MVideoFile- video: MVideoFullLight+ video: MVideoFull}): Promise<Readable> {const { video, videoFile, separatedAudioFile } = options@@ -482,7 +482,7 @@ export class VideosExporter extends AbstractUserExporter<VideoExportJSON> {// ---------------------------------------------------------------------------- private async getArchiveVideo (video: MVideoFullLight) {+ private async getArchiveVideo (video: MVideoFull) {const source = await VideoSourceModel.loadLatest(video.id)const { videoFile, separatedAudioFile } = video.getMaxQualityAudioAndVideoFiles()diff --git a/server/core/lib/user-import-export/importers/videos-importer.ts b/server/core/lib/user-import-export/importers/videos-importer.tsindex a7efc59b9e..28ad570a97 100644--- a/server/core/lib/user-import-export/importers/videos-importer.ts+++ b/server/core/lib/user-import-export/importers/videos-importer.ts@@ -38,7 +38,7 @@ import { PlayerSettingModel } from '@server/models/video/player-setting.js'import { VideoChannelModel } from '@server/models/video/video-channel.js'import { VideoEmbedPrivacyDomainModel } from '@server/models/video/video-embed-privacy-domain.js'import { VideoModel } from '@server/models/video/video.js'-import { MChannelId, MVideoFullLight } from '@server/types/models/index.js'+import { MChannelId, MVideoFull } from '@server/types/models/index.js'import { FfprobeData } from 'fluent-ffmpeg'import { parse } from 'path'import { AbstractUserImporter } from './abstract-user-importer.js'@@ -280,7 +280,7 @@ export class VideosImporter extends AbstractUserImporter<VideoExportJSON, Importreturn { duplicate: false }}- private async importCaptions (video: MVideoFullLight, videoImportData: SanitizedObject) {+ private async importCaptions (video: MVideoFull, videoImportData: SanitizedObject) {const captionPaths: string[] = []let updateHLS = false@@ -315,7 +315,7 @@ export class VideosImporter extends AbstractUserImporter<VideoExportJSON, Importreturn captionPaths}- private async importPlayerSettings (video: MVideoFullLight, videoImportData: SanitizedObject) {+ private async importPlayerSettings (video: MVideoFull, videoImportData: SanitizedObject) {const playerSettings = videoImportData.playerSettingsif (!playerSettings?.theme) return@@ -325,7 +325,7 @@ export class VideosImporter extends AbstractUserImporter<VideoExportJSON, Import})}- private async importVideoEmbedPrivacyDomains (video: MVideoFullLight, videoImportData: SanitizedObject) {+ private async importVideoEmbedPrivacyDomains (video: MVideoFull, videoImportData: SanitizedObject) {if (videoImportData.videoEmbedPrivacy.domains.length === 0) returnawait VideoEmbedPrivacyDomainModel.addDomains(videoImportData.videoEmbedPrivacy.domains, video.id)diff --git a/server/core/lib/video-blacklist.ts b/server/core/lib/video-blacklist.tsindex 073cfed452..74ada34939 100644--- a/server/core/lib/video-blacklist.ts+++ b/server/core/lib/video-blacklist.ts@@ -2,13 +2,15 @@ import { LiveVideoError, UserAdminFlag, UserRight, VideoBlacklistCreate, VideoBlimport { afterCommitIfTransaction } from '@server/helpers/database-utils.js'import { englishLanguage, t } from '@server/helpers/i18n.js'import { sequelizeTypescript } from '@server/initializers/database.js'+import { VideoModel } from '@server/models/video/video.js'import {MUser,MVideoAccountLight,MVideoBlacklist,MVideoBlacklistVideo,- MVideoFullLight,- MVideoWithBlacklistLight+ MVideoWithBlacklistLight,+ MVideoWithRights,+ MVideoWithSchedule} from '@server/types/models/index.js'import { Transaction } from 'sequelize'import { logger, loggerTagsFactory } from '../helpers/logger.js'@@ -88,7 +90,7 @@ export async function blacklistVideo (videoInstance: MVideoAccountLight, optionsNotifier.Instance.notifyOnVideoBlacklist(blacklist)}-export async function unblacklistVideo (videoBlacklist: MVideoBlacklist, video: MVideoFullLight) {+export async function unblacklistVideo (videoBlacklist: MVideoBlacklist, video: MVideoWithRights) {const videoBlacklistType = await sequelizeTypescript.transaction(async t => {const unfederated = videoBlacklist.unfederatedconst videoBlacklistType = videoBlacklist.type@@ -98,7 +100,7 @@ export async function unblacklistVideo (videoBlacklist: MVideoBlacklist, video:// Re federate the videoif (unfederated === true) {- await federateVideoIfNeeded(video, true, t)+ await federateVideoIfNeeded(await VideoModel.loadFull(video.id, t), true, t)}return videoBlacklistType@@ -107,11 +109,14 @@ export async function unblacklistVideo (videoBlacklist: MVideoBlacklist, video:Notifier.Instance.notifyOnVideoUnblacklist(video)if (videoBlacklistType === VideoBlacklistType.AUTO_BEFORE_PUBLISHED) {- Notifier.Instance.notifyOnVideoPublishedAfterRemovedFromAutoBlacklist(video)+ const videoWithSchedule = video as MVideoWithRights & MVideoWithSchedule+ videoWithSchedule.ScheduleVideoUpdate = await videoWithSchedule.$get('ScheduleVideoUpdate')++ Notifier.Instance.notifyOnVideoPublishedAfterRemovedFromAutoBlacklist(videoWithSchedule)// Delete on object so new video notifications will senddelete video.VideoBlacklist- Notifier.Instance.notifyOnNewVideoOrLiveIfNeeded(video)+ Notifier.Instance.notifyOnNewVideoOrLiveIfNeeded(videoWithSchedule)}}diff --git a/server/core/lib/video-captions.ts b/server/core/lib/video-captions.tsindex d3b6391d8e..024a9bd038 100644--- a/server/core/lib/video-captions.ts+++ b/server/core/lib/video-captions.ts@@ -12,7 +12,7 @@ import { VideoCaptionModel } from '@server/models/video/video-caption.js'import { VideoJobInfoModel } from '@server/models/video/video-job-info.js'import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist.js'import { VideoModel } from '@server/models/video/video.js'-import { MStreamingPlaylist, MVideo, MVideoCaption, MVideoFullLight, MVideoId, MVideoUUID, MVideoUrl } from '@server/types/models/index.js'+import { MStreamingPlaylist, MVideo, MVideoCaption, MVideoFull, MVideoId, MVideoUUID, MVideoUrl } from '@server/types/models/index.js'import { MutexInterface } from 'async-mutex'import { ensureDir, remove } from 'fs-extra/esm'import { writeFile } from 'fs/promises'@@ -219,7 +219,7 @@ export async function generateSubtitle (options: {}export async function onTranscriptionEnded (options: {- video: MVideoFullLight+ video: MVideoFulllanguage: stringvttPath: stringlTags?: (string | number)[]diff --git a/server/core/lib/video-comment.ts b/server/core/lib/video-comment.tsindex 83c396064c..731089daa6 100644--- a/server/core/lib/video-comment.ts+++ b/server/core/lib/video-comment.ts@@ -13,8 +13,7 @@ import {MCommentOwnerVideo,MCommentOwnerVideoReply,MUserAccountId,- MVideoAccountLight,- MVideoFullLight+ MVideoAccountLight} from '../types/models/index.js'import { sendCreateVideoCommentIfNeeded, sendDeleteVideoComment, sendReplyApproval } from './activitypub/send/index.js'import { getLocalVideoCommentActivityPubUrl } from './activitypub/url.js'@@ -71,7 +70,7 @@ export async function approveComment (commentArg: MComment) {export async function createLocalVideoComment (options: {text: stringinReplyToComment: MComment | null- video: MVideoFullLight+ video: MVideoAccountLightuser: MUserAccountId}) {const { user, video, text, inReplyToComment } = optionsdiff --git a/server/core/lib/video-download.ts b/server/core/lib/video-download.tsindex bccd71866e..c218a72f82 100644--- a/server/core/lib/video-download.ts+++ b/server/core/lib/video-download.ts@@ -4,7 +4,7 @@ import { getFFmpegCommandWrapperOptions } from '@server/helpers/ffmpeg/ffmpeg-opimport { logger } from '@server/helpers/logger.js'import { buildRequestError, doRequestAndSaveToFile, generateRequestStream } from '@server/helpers/requests.js'import { REQUEST_TIMEOUTS } from '@server/initializers/constants.js'-import { isWebVideoFile, MVideoFile, MVideoThumbnail } from '@server/types/models/index.js'+import { isWebVideoFile, MVideoFile, MVideoThumbnails } from '@server/types/models/index.js'import { createReadStream } from 'fs'import { remove } from 'fs-extra/esm'import { Readable, Writable } from 'stream'@@ -26,13 +26,13 @@ export class VideoDownload {private readonly tmpDestinations: string[] = []private ffmpegContainer: FFmpegContainer- private readonly video: MVideoThumbnail+ private readonly video: MVideoThumbnailsprivate readonly videoFiles: MVideoFile[]private allowDirectSending = trueconstructor (options: {- video: MVideoThumbnail+ video: MVideoThumbnailsvideoFiles: MVideoFile[]}) {this.video = options.videodiff --git a/server/core/lib/video-jobs.ts b/server/core/lib/video-jobs.tsindex 60b7dd71ed..ace3297cbe 100644--- a/server/core/lib/video-jobs.ts+++ b/server/core/lib/video-jobs.ts@@ -9,8 +9,8 @@ import {import { CONFIG } from '@server/initializers/config.js'import { VideoJobInfoModel } from '@server/models/video/video-job-info.js'import { VideoModel } from '@server/models/video/video.js'-import { MVideo, MVideoFile, MVideoFullLight, MVideoUUID } from '@server/types/models/index.js'-import { CreateJobTypeAndPayload, CreateJobOptions, JobQueue } from './job-queue/job-queue.js'+import { MVideo, MVideoFile, MVideoFull, MVideoUUID } from '@server/types/models/index.js'+import { CreateJobOptions, CreateJobTypeAndPayload, JobQueue } from './job-queue/job-queue.js'import { VideoStoryboardJobHandler } from './runners/index.js'import { createTranscriptionTaskIfNeeded } from './video-captions.js'import { moveFilesIfPrivacyChanged } from './video-privacy.js'@@ -171,7 +171,7 @@ export async function addVideoJobsAfterCreation (options: {}export async function addVideoJobsAfterUpdate (options: {- video: MVideoFullLight+ video: MVideoFullisNewVideoForFederation: booleannameChanged: booleandiff --git a/server/core/lib/video-playlist.ts b/server/core/lib/video-playlist.tsindex 2b40cb413d..53c6db1d97 100644--- a/server/core/lib/video-playlist.ts+++ b/server/core/lib/video-playlist.ts@@ -8,7 +8,7 @@ import { copy } from 'fs-extra/esm'import { extname, join } from 'path'import { Transaction } from 'sequelize'import { VideoPlaylistModel } from '../models/video/video-playlist.js'-import { MAccount, MVideoThumbnail } from '../types/models/index.js'+import { MAccount, MVideoThumbnails } from '../types/models/index.js'import { MVideoPlaylistOwner, MVideoPlaylistThumbnail } from '../types/models/video/video-playlist.js'import { sendUpdateVideoPlaylist } from './activitypub/send/send-update.js'import { getLocalVideoPlaylistActivityPubUrl } from './activitypub/url.js'@@ -32,7 +32,7 @@ export async function createWatchLaterPlaylist (account: MAccount, t: Transactioreturn videoPlaylist}-export async function generateThumbnailForPlaylist (videoPlaylist: MVideoPlaylistThumbnail, video: MVideoThumbnail) {+export async function generateThumbnailForPlaylist (videoPlaylist: MVideoPlaylistThumbnail, video: MVideoThumbnails) {logger.info('Generating default thumbnail to playlist %s.', videoPlaylist.url)const videoThumbnail = video.getBestThumbnail('16:9')diff --git a/server/core/lib/video-pre-import.ts b/server/core/lib/video-pre-import.tsindex db970e7496..4eefecd765 100644--- a/server/core/lib/video-pre-import.ts+++ b/server/core/lib/video-pre-import.ts@@ -34,7 +34,7 @@ import {MVideoAccountDefault,MVideoImportFormattable,MVideoTag,- MVideoThumbnail,+ MVideoThumbnails,MVideoWithBlacklistLight} from '@server/types/models/index.js'import express from 'express'@@ -47,7 +47,7 @@ import { replaceChapters, replaceChaptersFromDescriptionIfNeeded } from './video// ---------------------------------------------------------------------------export async function insertFromImportIntoDB (parameters: {- video: MVideoThumbnail+ video: MVideoThumbnailsthumbnails: MThumbnail[]videoChannel: MChannelAccountDefaulttags: string[]@@ -62,7 +62,7 @@ export async function insertFromImportIntoDB (parameters: {const videoCreated = await video.save(sequelizeOptions- ) as (MVideoAccountDefault & MVideoWithBlacklistLight & MVideoTag & MVideoThumbnail)+ ) as (MVideoAccountDefault & MVideoWithBlacklistLight & MVideoTag & MVideoThumbnails)videoCreated.VideoChannel = videoChannelif (thumbnails.length !== 0) {@@ -112,7 +112,7 @@ export async function buildVideoFromImport ({ channelId, importData, importDataOimportData: YoutubeDLInfoimportDataOverride?: Partial<VideoImportCreate>importType: 'url' | 'torrent'-}): Promise<MVideoThumbnail> {+}): Promise<MVideoThumbnails> {let videoData = {name: importDataOverride?.name || importData.name || 'Unknown name',remote: false,@@ -293,7 +293,7 @@ export async function buildYoutubeDLImport (options: {async function processThumbnails (options: {inputPath?: stringdownloadUrl?: string- video: MVideoThumbnail+ video: MVideoThumbnails}): Promise<MThumbnail[]> {const { inputPath, downloadUrl, video } = optionsdiff --git a/server/core/lib/video-privacy.ts b/server/core/lib/video-privacy.tsindex 60a4ac5fa0..7780943799 100644--- a/server/core/lib/video-privacy.ts+++ b/server/core/lib/video-privacy.ts@@ -1,7 +1,7 @@import { FileStorage, VideoPrivacy, VideoPrivacyType } from '@peertube/peertube-models'import { logger, loggerTagsFactory } from '@server/helpers/logger.js'import { DIRECTORIES } from '@server/initializers/constants.js'-import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models/index.js'+import { MVideo, MVideoFile, MVideoFull } from '@server/types/models/index.js'import { move } from 'fs-extra/esm'import { join } from 'path'import { updateHLSFilesACL, updateWebVideoFileACL } from './object-storage/index.js'@@ -30,7 +30,7 @@ export function isVideoInPublicDirectory (privacy: VideoPrivacyType) {return !isVideoInPrivateDirectory(privacy)}-export async function moveFilesIfPrivacyChanged (video: MVideoFullLight, oldPrivacy: VideoPrivacyType) {+export async function moveFilesIfPrivacyChanged (video: MVideoFull, oldPrivacy: VideoPrivacyType) {// Now public, previously privateif (isVideoInPublicDirectory(video.privacy) && isVideoInPrivateDirectory(oldPrivacy)) {await moveFiles({ type: 'private-to-public', video })@@ -56,7 +56,7 @@ type MoveType = 'private-to-public' | 'public-to-private'async function moveFiles (options: {type: MoveType- video: MVideoFullLight+ video: MVideoFull}) {const { type, video } = optionsdiff --git a/server/core/lib/video-state.ts b/server/core/lib/video-state.tsindex edc4238043..90601cd8a0 100644--- a/server/core/lib/video-state.ts+++ b/server/core/lib/video-state.ts@@ -4,7 +4,7 @@ import { logger, loggerTagsFactory } from '@server/helpers/logger.js'import { CONFIG } from '@server/initializers/config.js'import { sequelizeTypescript } from '@server/initializers/database.js'import { VideoModel } from '@server/models/video/video.js'-import { MVideo, MVideoFullLight, MVideoUUID } from '@server/types/models/index.js'+import { MVideo, MVideoFull, MVideoUUID } from '@server/types/models/index.js'import { Transaction } from 'sequelize'import { federateVideoIfNeeded } from './activitypub/videos/index.js'import { JobQueue } from './job-queue/index.js'@@ -82,7 +82,7 @@ export function moveToNextState (options: {// ---------------------------------------------------------------------------export async function moveToExternalStorageState (options: {- video: MVideoFullLight+ video: MVideoFullisNewVideo: booleantransaction: Transaction}) {@@ -114,7 +114,7 @@ export async function moveToExternalStorageState (options: {}export async function moveToFileSystemState (options: {- video: MVideoFullLight+ video: MVideoFullisNewVideo: booleantransaction: Transaction}) {@@ -173,7 +173,7 @@ export function moveToFailedMoveToFileSystemState (video: MVideo) {// ---------------------------------------------------------------------------async function moveToPublishedState (options: {- video: MVideoFullLight+ video: MVideoFullisNewVideo: booleantransaction: TransactionpreviousVideoState?: VideoStateTypediff --git a/server/core/lib/video-studio.ts b/server/core/lib/video-studio.tsindex 6321bae8d3..d920f03bd3 100644--- a/server/core/lib/video-studio.ts+++ b/server/core/lib/video-studio.ts@@ -5,7 +5,7 @@ import { logger, loggerTagsFactory } from '@server/helpers/logger.js'import { CONFIG } from '@server/initializers/config.js'import { createTorrentAndSetInfoHashFromPath } from '@server/lib/webtorrent.js'import { VideoModel } from '@server/models/video/video.js'-import { MUser, MVideoFile, MVideoFullLight, MVideoWithAllFiles, MVideoWithFile } from '@server/types/models/index.js'+import { MUser, MVideoFile, MVideoFull, MVideoWithAllFiles, MVideoWithFile } from '@server/types/models/index.js'import { move, remove } from 'fs-extra/esm'import { join } from 'path'import { JobQueue } from './job-queue/index.js'@@ -49,7 +49,7 @@ export async function safeCleanupStudioTMPFiles (tasks: VideoStudioTaskPayload[]// ---------------------------------------------------------------------------export async function approximateIntroOutroAdditionalSize (- video: MVideoFullLight,+ video: MVideoFull,tasks: VideoStudioTask[],fileFinder: (i: number) => string) {@@ -89,7 +89,7 @@ export async function createVideoStudioJob (options: {export async function onVideoStudioEnded (options: {editionResultPath: stringtasks: VideoStudioTaskPayload[]- video: MVideoFullLight+ video: MVideoFull}) {const { tasks, editionResultPath } = optionsdiff --git a/server/core/middlewares/validators/feeds.ts b/server/core/middlewares/validators/feeds.tsindex e55e62b97a..39ce68b237 100644--- a/server/core/middlewares/validators/feeds.ts+++ b/server/core/middlewares/validators/feeds.ts@@ -160,8 +160,8 @@ export const videoCommentsFeedsValidator = [}if (req.query.videoId) {- if (!await doesVideoExist(req.query.videoId, res)) return- if (!await checkCanSeeVideo({ req, res, paramId: req.query.videoId, video: res.locals.videoAll })) return+ if (!await doesVideoExist(req.query.videoId, res, 'with-rights')) return+ if (!await checkCanSeeVideo({ req, res, paramId: req.query.videoId, video: res.locals.videoWithRights })) return}return next()diff --git a/server/core/middlewares/validators/metrics.ts b/server/core/middlewares/validators/metrics.tsindex 77dd988d96..3087ddfe15 100644--- a/server/core/middlewares/validators/metrics.ts+++ b/server/core/middlewares/validators/metrics.ts@@ -51,7 +51,7 @@ const addPlaybackMetricValidator = [const body: PlaybackMetricCreate = req.bodyif (areValidationErrors(req, res)) return- if (!await doesVideoExist(body.videoId, res, 'unsafe-only-immutable-attributes')) return+ if (!await doesVideoExist(body.videoId, res, 'unsafe-immutable-only')) returnreturn next()}diff --git a/server/core/middlewares/validators/oembed.ts b/server/core/middlewares/validators/oembed.tsindex 32217f6931..4b01826071 100644--- a/server/core/middlewares/validators/oembed.ts+++ b/server/core/middlewares/validators/oembed.ts@@ -1,10 +1,10 @@-import express from 'express'-import { query } from 'express-validator'-import { join } from 'path'import { HttpStatusCode, VideoPlaylistPrivacy, VideoPrivacy } from '@peertube/peertube-models'import { isTestOrDevInstance } from '@peertube/peertube-node-utils'-import { loadVideo } from '@server/lib/model-loaders/index.js'import { VideoPlaylistModel } from '@server/models/video/video-playlist.js'+import { VideoModel } from '@server/models/video/video.js'+import express from 'express'+import { query } from 'express-validator'+import { join } from 'path'import { isIdOrUUIDValid, isUUIDValid, toCompleteUUID } from '../../helpers/custom-validators/misc.js'import { WEBSERVER } from '../../initializers/constants.js'import { areValidationErrors } from './shared/index.js'@@ -101,7 +101,7 @@ const oembedValidator = [}if (isVideo) {- const video = await loadVideo(elementId, 'all')+ const video = await VideoModel.loadWithRights(elementId)if (!video) {return res.fail({@@ -112,9 +112,10 @@ const oembedValidator = [if (video.privacy === VideoPrivacy.PUBLIC ||- (video.privacy === VideoPrivacy.UNLISTED && isUUIDValid(elementId) === true)+ (video.privacy === VideoPrivacy.UNLISTED && isUUIDValid(elementId) === true) ||+ video.VideoBlacklist) {- res.locals.videoAll = video+ res.locals.videoWithRights = videoreturn next()}@@ -147,7 +148,6 @@ const oembedValidator = [message: 'Playlist is not public'})}-]// ---------------------------------------------------------------------------diff --git a/server/core/middlewares/validators/player-settings.ts b/server/core/middlewares/validators/player-settings.tsindex 539b28c3b4..e3d52d6aad 100644--- a/server/core/middlewares/validators/player-settings.ts+++ b/server/core/middlewares/validators/player-settings.ts@@ -20,9 +20,9 @@ export const getVideoPlayerSettingsValidator = [const raw = req.query.raw === true- if (!await doesVideoExist(req.params.videoId, res, raw ? 'all' : 'only-video-and-blacklist')) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-rights')) return- const video = res.locals.onlyVideo || res.locals.videoAll+ const video = res.locals.videoWithRightsif (!await checkCanSeeVideo({ req, res, video, paramId: req.params.videoId })) returnif (raw === true) {@@ -31,7 +31,7 @@ export const getVideoPlayerSettingsValidator = [if (!await checkCanManageVideo({user,- video: res.locals.videoAll,+ video,right: UserRight.UPDATE_ANY_VIDEO,req,res,@@ -82,13 +82,13 @@ export const updateVideoPlayerSettingsValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res, 'all')) return+ if (!await doesVideoExist(req.params.videoId, res, 'full')) returnconst user = res.locals.oauth.token.Userif (!await checkCanManageVideo({user,- video: res.locals.videoAll,+ video: res.locals.videoFull,right: UserRight.UPDATE_ANY_VIDEO,req,res,diff --git a/server/core/middlewares/validators/redundancy.ts b/server/core/middlewares/validators/redundancy.tsindex 6389ede241..df39fa542c 100644--- a/server/core/middlewares/validators/redundancy.ts+++ b/server/core/middlewares/validators/redundancy.ts@@ -29,7 +29,7 @@ const videoPlaylistRedundancyGetValidator = [if (areValidationErrors(req, res)) returnif (!await doesVideoExist(req.params.videoId, res)) return- const video = res.locals.videoAll+ const video = res.locals.videoFullif (!canVideoBeFederated(video)) return res.sendStatus(HttpStatusCode.NOT_FOUND_404)const paramPlaylistType = req.params.streamingPlaylistType as unknown as number // We casted to int above@@ -100,17 +100,17 @@ const addVideoRedundancyValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.body.videoId, res, 'only-video-and-blacklist')) return+ if (!await doesVideoExist(req.body.videoId, res, 'with-blacklist')) return- if (res.locals.onlyVideo.remote === false) {+ if (res.locals.videoWithBlacklist.remote === false) {return res.fail({ message: 'Cannot create a redundancy on a local video' })}- if (res.locals.onlyVideo.isLive) {+ if (res.locals.videoWithBlacklist.isLive) {return res.fail({ message: 'Cannot create a redundancy of a live video' })}- const alreadyExists = await VideoRedundancyModel.isLocalByVideoUUIDExists(res.locals.onlyVideo.uuid)+ const alreadyExists = await VideoRedundancyModel.isLocalByVideoUUIDExists(res.locals.videoWithBlacklist.uuid)if (alreadyExists) {return res.fail({status: HttpStatusCode.CONFLICT_409,diff --git a/server/core/middlewares/validators/runners/job-files.ts b/server/core/middlewares/validators/runners/job-files.tsindex 8bfd2cce79..41be0bbae5 100644--- a/server/core/middlewares/validators/runners/job-files.ts+++ b/server/core/middlewares/validators/runners/job-files.ts@@ -13,15 +13,15 @@ export const runnerJobGetVideoTranscodingFileValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res, 'all')) return+ if (!await doesVideoExist(req.params.videoId, res, 'full')) returnconst runnerJob = res.locals.runnerJob- if (runnerJob.privatePayload.videoUUID !== res.locals.videoAll.uuid) {+ if (runnerJob.privatePayload.videoUUID !== res.locals.videoFull.uuid) {return res.fail({status: HttpStatusCode.FORBIDDEN_403,message: 'Job is not associated to this video',- tags: [ ...tags, res.locals.videoAll.uuid ]+ tags: [ ...tags, res.locals.videoFull.uuid ]})}@@ -51,7 +51,7 @@ export const runnerJobGetVideoStudioTaskFileValidator = [return res.fail({status: HttpStatusCode.BAD_REQUEST_400,message: 'File is not associated to this edition task',- tags: [ ...tags, res.locals.videoAll.uuid ]+ tags: [ ...tags, res.locals.videoFull.uuid ]})}diff --git a/server/core/middlewares/validators/shared/videos.ts b/server/core/middlewares/validators/shared/videos.tsindex 5dd304dbae..304a24f0c8 100644--- a/server/core/middlewares/validators/shared/videos.ts+++ b/server/core/middlewares/validators/shared/videos.ts@@ -14,17 +14,18 @@ import {MVideo,MVideoAccountLight,MVideoFormattableDetails,- MVideoFullLight,+ MVideoFull,MVideoId,MVideoImmutable,- MVideoThumbnailBlacklist,+ MVideoThumbnails,MVideoUUID,+ MVideoWithBlacklist,MVideoWithRights} from '@server/types/models/index.js'import { Request, Response } from 'express'import { checkCanManageChannel } from './video-channels.js'-export async function doesVideoExist (id: number | string, res: Response, fetchType: VideoLoadType = 'all') {+export async function doesVideoExist (id: number | string, res: Response, fetchType: VideoLoadType = 'full') {const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefinedconst video = await loadVideo(id, fetchType, userId)@@ -43,21 +44,33 @@ export async function doesVideoExist (id: number | string, res: Response, fetchTres.locals.videoAPI = video as MVideoFormattableDetailsbreak- case 'all':- res.locals.videoAll = video as MVideoFullLight+ case 'full':+ res.locals.videoFull = video as MVideoFullbreak- case 'unsafe-only-immutable-attributes':- res.locals.onlyImmutableVideo = video as MVideoImmutable+ case 'unsafe-immutable-only':+ res.locals.videoImmutable = video as MVideoImmutablebreak+ case 'none':case 'id':res.locals.videoId = video as MVideoIdbreak- case 'only-video-and-blacklist':- res.locals.onlyVideo = video as MVideoThumbnailBlacklist+ case 'with-blacklist':+ res.locals.videoWithBlacklist = video as MVideoWithBlacklistbreak++ case 'with-thumbnails':+ res.locals.videoThumbnails = video as MVideoThumbnails+ break++ case 'with-rights':+ res.locals.videoWithRights = video as MVideoWithRights+ break++ default:+ return fetchType satisfies never}return true@@ -221,7 +234,7 @@ async function getVideoWithRights (video: MVideoWithRights): Promise<MVideoWithRif (channel?.id && channel?.Account?.userId && channel?.Account?.id) return video- return VideoModel.loadFull(video.id)+ return VideoModel.loadWithRights(video.id)}// ---------------------------------------------------------------------------@@ -246,7 +259,7 @@ export async function checkCanAccessVideoSourceFile (options: {}): Promise<boolean> {const { req, res, videoId } = options- const video = await VideoModel.loadFull(videoId)+ const video = await VideoModel.loadWithRights(videoId)let user = res.locals.oauth?.token.Userif (!user) {diff --git a/server/core/middlewares/validators/static.ts b/server/core/middlewares/validators/static.tsindex 5d919cd898..252da7dad3 100644--- a/server/core/middlewares/validators/static.ts+++ b/server/core/middlewares/validators/static.ts@@ -10,7 +10,7 @@ import { logger } from '@server/helpers/logger.js'import { LRU_CACHE } from '@server/initializers/constants.js'import { VideoFileModel } from '@server/models/video/video-file.js'import { VideoModel } from '@server/models/video/video.js'-import { MVideoFile, MVideoThumbnailBlacklist } from '@server/types/models/index.js'+import { MVideoFile, MVideoWithBlacklist } from '@server/types/models/index.js'import express from 'express'import { param, query } from 'express-validator'import { LRUCache } from 'lru-cache'@@ -19,7 +19,7 @@ import { areValidationErrors, checkCanAccessVideoStaticFiles, isValidVideoPasswotype LRUValue = {allowed: boolean- video?: MVideoThumbnailBlacklist+ video?: MVideoWithBlacklistfile?: MVideoFile}@@ -45,7 +45,7 @@ export const ensureCanAccessVideoPrivateWebVideoFiles = [const { allowed, file, video } = staticFileTokenBypass.get(cacheKey)if (allowed === true) {- res.locals.onlyVideo = video+ res.locals.videoWithBlacklist = videores.locals.videoFile = filereturn next()@@ -60,7 +60,7 @@ export const ensureCanAccessVideoPrivateWebVideoFiles = [if (result.allowed !== true) return- res.locals.onlyVideo = result.video+ res.locals.videoWithBlacklist = result.videores.locals.videoFile = result.filereturn next()@@ -121,7 +121,7 @@ export const ensureCanAccessPrivateVideoHLSFiles = [const { allowed, file, video } = staticFileTokenBypass.get(cacheKey)if (allowed === true) {- res.locals.onlyVideo = video+ res.locals.videoWithBlacklist = videores.locals.videoFile = filereturn next()@@ -136,7 +136,7 @@ export const ensureCanAccessPrivateVideoHLSFiles = [if (result.allowed !== true) return- res.locals.onlyVideo = result.video+ res.locals.videoWithBlacklist = result.videores.locals.videoFile = result.filereturn next()@@ -168,7 +168,7 @@ async function isWebVideoAllowed (req: express.Request, res: express.Response) {async function isHLSAllowed (req: express.Request, res: express.Response, videoUUID: string) {const filename = basename(req.path)- const video = await VideoModel.loadAndPopulateAccountAndFiles(videoUUID)+ const video = await VideoModel.loadWithBlacklist(videoUUID)if (!video) {logger.debug('Unknown static file %s to serve', req.originalUrl, { videoUUID })diff --git a/server/core/middlewares/validators/videos/video-blacklist.ts b/server/core/middlewares/validators/videos/video-blacklist.tsindex 8790a02a66..666d8061d5 100644--- a/server/core/middlewares/validators/videos/video-blacklist.ts+++ b/server/core/middlewares/validators/videos/video-blacklist.ts@@ -5,19 +5,19 @@ import { isBooleanValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/cimport { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist.js'import { areValidationErrors, doesVideoBlacklistExist, doesVideoExist, isValidVideoIdParam } from '../shared/index.js'-const videosBlacklistRemoveValidator = [+export const videosBlacklistRemoveValidator = [isValidVideoIdParam('videoId'),async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res)) return- if (!await doesVideoBlacklistExist(res.locals.videoAll.id, res)) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-rights')) return+ if (!await doesVideoBlacklistExist(res.locals.videoWithRights.id, res)) returnreturn next()}]-const videosBlacklistAddValidator = [+export const videosBlacklistAddValidator = [isValidVideoIdParam('videoId'),body('unfederate')@@ -30,13 +30,13 @@ const videosBlacklistAddValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res)) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-rights')) return- const video = res.locals.videoAll+ const video = res.locals.videoWithRightsif (req.body.unfederate === true && video.remote === true) {return res.fail({status: HttpStatusCode.CONFLICT_409,- message: 'You cannot unfederate a remote video.'+ message: req.t('You cannot unfederate a remote video.')})}@@ -44,7 +44,7 @@ const videosBlacklistAddValidator = [}]-const videosBlacklistUpdateValidator = [+export const videosBlacklistUpdateValidator = [isValidVideoIdParam('videoId'),body('reason')@@ -53,16 +53,16 @@ const videosBlacklistUpdateValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res)) return- if (!await doesVideoBlacklistExist(res.locals.videoAll.id, res)) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-rights')) return+ if (!await doesVideoBlacklistExist(res.locals.videoWithRights.id, res)) returnreturn next()}]-const videosBlacklistFiltersValidator = [+export const videosBlacklistFiltersValidator = [query('type')- .optional()+ .optional().customSanitizer(toIntOrNull).custom(isVideoBlacklistTypeValid).withMessage('Should have a valid video blacklist type attribute'),query('search')@@ -76,12 +76,3 @@ const videosBlacklistFiltersValidator = [return next()}]--// -----------------------------------------------------------------------------export {- videosBlacklistAddValidator,- videosBlacklistRemoveValidator,- videosBlacklistUpdateValidator,- videosBlacklistFiltersValidator-}diff --git a/server/core/middlewares/validators/videos/video-captions.ts b/server/core/middlewares/validators/videos/video-captions.tsindex 2663a011fd..5ee81ed4b2 100644--- a/server/core/middlewares/validators/videos/video-captions.ts+++ b/server/core/middlewares/validators/videos/video-captions.ts@@ -10,8 +10,8 @@ import { cleanUpReqFiles } from '../../../helpers/express-utils.js'import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../../initializers/constants.js'import {areValidationErrors,- checkCanSeeVideo,checkCanManageVideo,+ checkCanSeeVideo,doesVideoCaptionExist,doesVideoExist,isValidVideoIdParam,@@ -30,20 +30,20 @@ export const addVideoCaptionValidator = [.withMessage('This caption file is not supported or too large. ' +`Please, make sure it is under ${CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max} bytes ` +- 'and one of the following mimetypes: ' ++ 'and one of the following mime types: ' +Object.keys(MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT).map(key => `${key} (${MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT[key]})`).join(', ')),async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return cleanUpReqFiles(req)- if (!await doesVideoExist(req.params.videoId, res)) return cleanUpReqFiles(req)+ if (!await doesVideoExist(req.params.videoId, res, 'full')) return cleanUpReqFiles(req)// Check if the user who did the request is able to update the videoconst user = res.locals.oauth.token.Userif (!await checkCanManageVideo({user,- video: res.locals.videoAll,+ video: res.locals.videoFull,right: UserRight.UPDATE_ANY_VIDEO,req,res,@@ -72,13 +72,13 @@ export const generateVideoCaptionValidator = [if (CONFIG.VIDEO_TRANSCRIPTION.ENABLED !== true) {return res.fail({status: HttpStatusCode.BAD_REQUEST_400,- message: 'Video transcription is disabled on this instance'+ message: req.t('Video transcription is disabled on this instance')})}- if (!await doesVideoExist(req.params.videoId, res)) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-rights')) return- const video = res.locals.videoAll+ const video = res.locals.videoWithRightsif (!checkVideoCanBeTranscribedOrTranscoded({ video, req, res })) return@@ -94,7 +94,7 @@ export const generateVideoCaptionValidator = [return res.fail({status: HttpStatusCode.BAD_REQUEST_400,type: ServerErrorCode.VIDEO_ALREADY_HAS_CAPTIONS,- message: 'This video already has captions'+ message: req.t('This video already has captions')})}@@ -104,7 +104,7 @@ export const generateVideoCaptionValidator = [if (user.hasRight(UserRight.UPDATE_ANY_VIDEO) !== true) {return res.fail({status: HttpStatusCode.FORBIDDEN_403,- message: 'Only admins can force transcription'+ message: req.t('Only admins can force transcription')})}@@ -116,7 +116,7 @@ export const generateVideoCaptionValidator = [return res.fail({status: HttpStatusCode.CONFLICT_409,type: ServerErrorCode.VIDEO_ALREADY_BEING_TRANSCRIBED,- message: 'This video is already being transcribed'+ message: req.t('This video is already being transcribed')})}@@ -133,14 +133,14 @@ export const deleteVideoCaptionValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) returnif (!await doesVideoExist(req.params.videoId, res)) return- if (!await doesVideoCaptionExist(res.locals.videoAll, req.params.captionLanguage, res)) return+ if (!await doesVideoCaptionExist(res.locals.videoFull, req.params.captionLanguage, res)) return// Check if the user who did the request is able to update the videoconst user = res.locals.oauth.token.Userif (!await checkCanManageVideo({user,- video: res.locals.videoAll,+ video: res.locals.videoFull,right: UserRight.UPDATE_ANY_VIDEO,req,res,@@ -160,9 +160,9 @@ export const listVideoCaptionsValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res, 'only-video-and-blacklist')) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-blacklist')) return- const video = res.locals.onlyVideo+ const video = res.locals.videoWithBlacklistif (!await checkCanSeeVideo({ req, res, video, paramId: req.params.videoId })) returnreturn next()diff --git a/server/core/middlewares/validators/videos/video-chapters.ts b/server/core/middlewares/validators/videos/video-chapters.tsindex e7a0912afa..02bda95edc 100644--- a/server/core/middlewares/validators/videos/video-chapters.ts+++ b/server/core/middlewares/validators/videos/video-chapters.ts@@ -15,10 +15,10 @@ export const updateVideoChaptersValidator = [if (areValidationErrors(req, res)) returnif (!await doesVideoExist(req.params.videoId, res)) return- if (res.locals.videoAll.isLive) {+ if (res.locals.videoFull.isLive) {return res.fail({status: HttpStatusCode.BAD_REQUEST_400,- message: 'You cannot add chapters to a live video'+ message: req.t('You cannot add chapters to a live video')})}@@ -27,7 +27,7 @@ export const updateVideoChaptersValidator = [if (!await checkCanManageVideo({user,- video: res.locals.videoAll,+ video: res.locals.videoFull,right: UserRight.UPDATE_ANY_VIDEO,req,res,diff --git a/server/core/middlewares/validators/videos/video-comments.ts b/server/core/middlewares/validators/videos/video-comments.tsindex ed8dd9ed58..2c979dffc8 100644--- a/server/core/middlewares/validators/videos/video-comments.ts+++ b/server/core/middlewares/validators/videos/video-comments.ts@@ -19,7 +19,7 @@ import { isValidVideoCommentText } from '../../../helpers/custom-validators/videimport { logger } from '../../../helpers/logger.js'import { AcceptResult, isLocalVideoCommentReplyAccepted, isLocalVideoThreadAccepted } from '../../../lib/moderation.js'import { Hooks } from '../../../lib/plugins/hooks.js'-import { MCommentOwnerVideoReply, MVideo, MVideoFullLight } from '../../../types/models/video/index.js'+import { MCommentOwnerVideoReply, MVideo, MVideoAccountLight } from '../../../types/models/video/index.js'import {areValidationErrors,checkCanManageChannel,@@ -51,7 +51,7 @@ export const listAllVideoCommentsForAdminValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (req.query.videoId && !await doesVideoExist(req.query.videoId, res, 'unsafe-only-immutable-attributes')) return+ if (req.query.videoId && !await doesVideoExist(req.query.videoId, res, 'unsafe-immutable-only')) returnif (req.query.videoChannelId &&!await doesChannelIdExist({ id: req.query.videoChannelId, checkCanManage: true, checkIsOwner: false, checkIsLocal: true, req, res })@@ -75,7 +75,7 @@ export const listCommentsOnUserVideosValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (req.query.videoId && !await doesVideoExist(req.query.videoId, res, 'all')) return+ if (req.query.videoId && !await doesVideoExist(req.query.videoId, res, 'with-rights')) returnif (req.query.videoChannelId &&@@ -92,7 +92,7 @@ export const listCommentsOnUserVideosValidator = [const user = res.locals.oauth.token.User- const video = res.locals.videoAll+ const video = res.locals.videoWithRightsif (video &&!await checkCanManageVideo({ user, video, right: UserRight.SEE_ALL_COMMENTS, req, res, checkIsLocal: true, checkIsOwner: false })@@ -110,9 +110,9 @@ export const listVideoCommentThreadsValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res, 'only-video-and-blacklist')) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-blacklist')) return- if (!await checkCanSeeVideo({ req, res, paramId: req.params.videoId, video: res.locals.onlyVideo })) return+ if (!await checkCanSeeVideo({ req, res, paramId: req.params.videoId, video: res.locals.videoWithBlacklist })) returnreturn next()}@@ -127,10 +127,10 @@ export const listVideoThreadCommentsValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res, 'only-video-and-blacklist')) return- if (!await doesVideoCommentThreadExist(req.params.threadId, res.locals.onlyVideo, res)) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-blacklist')) return+ if (!await doesVideoCommentThreadExist(req.params.threadId, res.locals.videoWithBlacklist, res)) return- if (!await checkCanSeeVideo({ req, res, paramId: req.params.videoId, video: res.locals.onlyVideo })) return+ if (!await checkCanSeeVideo({ req, res, paramId: req.params.videoId, video: res.locals.videoWithBlacklist })) returnreturn next()}@@ -145,12 +145,12 @@ export const addVideoCommentThreadValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res)) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-rights')) return- if (!await checkCanSeeVideo({ req, res, paramId: req.params.videoId, video: res.locals.videoAll })) return+ if (!await checkCanSeeVideo({ req, res, paramId: req.params.videoId, video: res.locals.videoWithRights })) return- if (!isVideoCommentsEnabled(res.locals.videoAll, res)) return- if (!await isVideoCommentAccepted(req, res, res.locals.videoAll, false)) return+ if (!isVideoCommentsEnabled(res.locals.videoWithRights, res)) return+ if (!await isVideoCommentAccepted(req, res, res.locals.videoWithRights, false)) returnreturn next()}@@ -166,13 +166,13 @@ export const addVideoCommentReplyValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res)) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-rights')) return- if (!await checkCanSeeVideo({ req, res, paramId: req.params.videoId, video: res.locals.videoAll })) return+ if (!await checkCanSeeVideo({ req, res, paramId: req.params.videoId, video: res.locals.videoWithRights })) return- if (!isVideoCommentsEnabled(res.locals.videoAll, res)) return- if (!await doesVideoCommentExist(req.params.commentId, res.locals.videoAll, res)) return- if (!await isVideoCommentAccepted(req, res, res.locals.videoAll, true)) return+ if (!isVideoCommentsEnabled(res.locals.videoWithRights, res)) return+ if (!await doesVideoCommentExist(req.params.commentId, res.locals.videoWithRights, res)) return+ if (!await isVideoCommentAccepted(req, res, res.locals.videoWithRights, true)) returnreturn next()}@@ -186,11 +186,11 @@ export const videoCommentGetValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res, 'only-video-and-blacklist')) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-blacklist')) return- if (!canVideoBeFederated(res.locals.onlyVideo)) return res.sendStatus(HttpStatusCode.NOT_FOUND_404)+ if (!canVideoBeFederated(res.locals.videoWithBlacklist)) return res.sendStatus(HttpStatusCode.NOT_FOUND_404)- if (!await doesVideoCommentExist(req.params.commentId, res.locals.onlyVideo, res)) return+ if (!await doesVideoCommentExist(req.params.commentId, res.locals.videoWithBlacklist, res)) returnreturn next()}@@ -204,8 +204,8 @@ export const removeVideoCommentValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res)) return- if (!await doesVideoCommentExist(req.params.commentId, res.locals.videoAll, res)) return+ if (!await doesVideoExist(req.params.videoId, res, 'unsafe-immutable-only')) return+ if (!await doesVideoCommentExist(req.params.commentId, res.locals.videoImmutable, res)) returnif (!await checkCanDeleteVideoComment({ user: res.locals.oauth.token.User, videoComment: res.locals.videoCommentFull, req, res })) {return@@ -223,8 +223,8 @@ export const approveVideoCommentValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res)) return- if (!await doesVideoCommentExist(req.params.commentId, res.locals.videoAll, res)) return+ if (!await doesVideoExist(req.params.videoId, res, 'unsafe-immutable-only')) return+ if (!await doesVideoCommentExist(req.params.commentId, res.locals.videoImmutable, res)) returnif (!await checkCanApproveVideoComment({ user: res.locals.oauth.token.User, videoComment: res.locals.videoCommentFull, req, res })) {return@@ -322,7 +322,7 @@ async function checkCanManageCommentsOfVideo (options: {return false}-async function isVideoCommentAccepted (req: express.Request, res: express.Response, video: MVideoFullLight, isReply: boolean) {+async function isVideoCommentAccepted (req: express.Request, res: express.Response, video: MVideoAccountLight, isReply: boolean) {const acceptParameters = {video,commentBody: req.body,diff --git a/server/core/middlewares/validators/videos/video-embed-privacy.ts b/server/core/middlewares/validators/videos/video-embed-privacy.tsindex b6462c6418..97c71164ea 100644--- a/server/core/middlewares/validators/videos/video-embed-privacy.ts+++ b/server/core/middlewares/validators/videos/video-embed-privacy.ts@@ -13,7 +13,7 @@ export const isVideoEmbedOnDomainAllowedValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res, 'only-video-and-blacklist')) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-blacklist')) returnreturn next()}@@ -24,12 +24,12 @@ export const getVideoEmbedPrivacyValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res)) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-rights')) returnif (!await checkCanManageVideo({user: res.locals.oauth.token.User,- video: res.locals.videoAll,+ video: res.locals.videoWithRights,right: UserRight.UPDATE_ANY_VIDEO,checkIsOwner: false,checkIsLocal: true,@@ -54,12 +54,12 @@ export const updateVideoEmbedPrivacyValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res)) return+ if (!await doesVideoExist(req.params.videoId, res, 'full')) returnif (!await checkCanManageVideo({user: res.locals.oauth.token.User,- video: res.locals.videoAll,+ video: res.locals.videoFull,right: UserRight.UPDATE_ANY_VIDEO,checkIsOwner: false,checkIsLocal: true,diff --git a/server/core/middlewares/validators/videos/video-files.ts b/server/core/middlewares/validators/videos/video-files.tsindex d5d743f594..9c4c8e5247 100644--- a/server/core/middlewares/validators/videos/video-files.ts+++ b/server/core/middlewares/validators/videos/video-files.ts@@ -12,7 +12,7 @@ export const videoFilesDeleteWebVideoValidator = [if (areValidationErrors(req, res)) returnif (!await doesVideoExist(req.params.id, res)) return- const video = res.locals.videoAll+ const video = res.locals.videoFullif (!checkLocalVideo(video, res)) return@@ -44,7 +44,7 @@ export const videoFilesDeleteWebVideoFileValidator = [if (areValidationErrors(req, res)) returnif (!await doesVideoExist(req.params.id, res)) return- const video = res.locals.videoAll+ const video = res.locals.videoFullif (!checkLocalVideo(video, res)) return@@ -76,7 +76,7 @@ export const videoFilesDeleteHLSValidator = [if (areValidationErrors(req, res)) returnif (!await doesVideoExist(req.params.id, res)) return- const video = res.locals.videoAll+ const video = res.locals.videoFullif (!checkLocalVideo(video, res)) return@@ -108,7 +108,7 @@ export const videoFilesDeleteHLSFileValidator = [if (areValidationErrors(req, res)) returnif (!await doesVideoExist(req.params.id, res)) return- const video = res.locals.videoAll+ const video = res.locals.videoFullif (!checkLocalVideo(video, res)) returndiff --git a/server/core/middlewares/validators/videos/video-live.ts b/server/core/middlewares/validators/videos/video-live.tsindex f5b75490b1..09883a10e9 100644--- a/server/core/middlewares/validators/videos/video-live.ts+++ b/server/core/middlewares/validators/videos/video-live.ts@@ -8,7 +8,9 @@ import {VideoState} from '@peertube/peertube-models'import { areLiveSchedulesValid, isLiveLatencyModeValid } from '@server/helpers/custom-validators/video-lives.js'+import { getVideoWithAttributes } from '@server/helpers/video.js'import { CONSTRAINTS_FIELDS } from '@server/initializers/constants.js'+import { VideoLoadType } from '@server/lib/model-loaders/video.js'import { isLocalLiveVideoAccepted } from '@server/lib/moderation.js'import { Hooks } from '@server/lib/plugins/hooks.js'import { VideoLiveSessionModel } from '@server/models/video/video-live-session.js'@@ -24,26 +26,25 @@ import { CONFIG } from '../../../initializers/config.js'import { areValidationErrors, checkCanManageVideo, doesChannelIdExist, doesVideoExist, isValidVideoIdParam } from '../shared/index.js'import { areErrorsInNSFW, getCommonVideoEditAttributes } from './videos.js'-export const videoLiveGetValidator = [- isValidVideoIdParam('videoId'),+export const videoLiveGetValidatorFactory = (loadType: VideoLoadType) => {+ return [+ isValidVideoIdParam('videoId'),- async (req: express.Request, res: express.Response, next: express.NextFunction) => {- if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res, 'all')) return+ async (req: express.Request, res: express.Response, next: express.NextFunction) => {+ if (areValidationErrors(req, res)) return+ if (!await doesVideoExist(req.params.videoId, res, loadType)) return- const videoLive = await VideoLiveModel.loadByVideoIdFull(res.locals.videoAll.id)- if (!videoLive) {- return res.fail({- status: HttpStatusCode.NOT_FOUND_404,- message: 'Live video not found'- })- }+ const videoLive = await VideoLiveModel.loadByVideoIdFull(getVideoWithAttributes(res).id)+ if (!videoLive) {+ return res.sendStatus(HttpStatusCode.NOT_FOUND_404)+ }- res.locals.videoLive = videoLive+ res.locals.videoLive = videoLive- return next()- }-]+ return next()+ }+ ]+}export const videoLiveAddValidator = getCommonVideoEditAttributes().concat([body('channelId')@@ -202,7 +203,7 @@ export const videoLiveUpdateValidator = [if (!checkLiveSettingsReplayConsistency({ res, body })) return- if (res.locals.videoAll.state !== VideoState.WAITING_FOR_LIVE) {+ if (res.locals.videoFull.state !== VideoState.WAITING_FOR_LIVE) {return res.fail({ message: 'Cannot update a live that has already started' })}@@ -211,7 +212,7 @@ export const videoLiveUpdateValidator = [if (!await checkCanManageVideo({user,- video: res.locals.videoAll,+ video: res.locals.videoFull,right: UserRight.GET_ANY_LIVE,req,res,@@ -231,7 +232,7 @@ export const videoLiveListSessionsValidator = [if (!await checkCanManageVideo({user,- video: res.locals.videoAll,+ video: res.locals.videoWithRights,right: UserRight.GET_ANY_LIVE,req,res,diff --git a/server/core/middlewares/validators/videos/video-ownership-changes.ts b/server/core/middlewares/validators/videos/video-ownership-changes.tsindex f1454c7e94..4edba2bb80 100644--- a/server/core/middlewares/validators/videos/video-ownership-changes.ts+++ b/server/core/middlewares/validators/videos/video-ownership-changes.ts@@ -21,13 +21,13 @@ export const videosChangeOwnershipValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res)) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-rights')) return// Check if the user who did the request is able to change the ownership of the videoif (!await checkCanManageVideo({user: res.locals.oauth.token.User,- video: res.locals.videoAll,+ video: res.locals.videoWithRights,right: UserRight.CHANGE_VIDEO_OWNERSHIP,checkIsOwner: false,checkIsLocal: true,diff --git a/server/core/middlewares/validators/videos/video-passwords.ts b/server/core/middlewares/validators/videos/video-passwords.tsindex aa6fef8d3c..6b6d3b774a 100644--- a/server/core/middlewares/validators/videos/video-passwords.ts+++ b/server/core/middlewares/validators/videos/video-passwords.ts@@ -7,10 +7,10 @@ import {areValidationErrors,checkCanDeleteVideoPassword,checkCanManageVideo,+ checkVideoIsPasswordProtected,doesVideoExist,doesVideoPasswordExist,- isValidVideoIdParam,- checkVideoIsPasswordProtected+ isValidVideoIdParam} from '../shared/index.js'export const listVideoPasswordValidator = [@@ -19,7 +19,7 @@ export const listVideoPasswordValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res)) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-rights')) returnif (!checkVideoIsPasswordProtected(req, res)) return// Check if the user who did the request is able to access video password list@@ -27,7 +27,7 @@ export const listVideoPasswordValidator = [if (!await checkCanManageVideo({user,- video: res.locals.videoAll,+ video: res.locals.videoWithRights,right: UserRight.SEE_ALL_VIDEOS,req,res,@@ -83,11 +83,11 @@ export const removeVideoPasswordValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res)) return+ if (!await doesVideoExist(req.params.videoId, res, 'with-rights')) returnif (!checkVideoIsPasswordProtected(req, res)) returnif (!await doesVideoPasswordExist({ id: req.params.passwordId, req, res })) return- if (!await checkCanDeleteVideoPassword({ user: res.locals.oauth.token.User, video: res.locals.videoAll, req, res })) return+ if (!await checkCanDeleteVideoPassword({ user: res.locals.oauth.token.User, video: res.locals.videoWithRights, req, res })) returnreturn next()}@@ -98,7 +98,7 @@ export const removeVideoPasswordValidator = [// ---------------------------------------------------------------------------async function checkAddOrUpdatePasswords (req: express.Request, res: express.Response) {- if (!await doesVideoExist(req.params.videoId, res)) return false+ if (!await doesVideoExist(req.params.videoId, res, 'with-rights')) return falseif (!isValidPasswordProtectedPrivacy(req, res)) return false// Check if the user who did the request is able to update video passwords@@ -106,7 +106,7 @@ async function checkAddOrUpdatePasswords (req: express.Request, res: express.Resif (!await checkCanManageVideo({user,- video: res.locals.videoAll,+ video: res.locals.videoWithRights,right: UserRight.UPDATE_ANY_VIDEO,req,res,diff --git a/server/core/middlewares/validators/videos/video-playlists.ts b/server/core/middlewares/validators/videos/video-playlists.tsindex bf333c08db..8fefed9206 100644--- a/server/core/middlewares/validators/videos/video-playlists.ts+++ b/server/core/middlewares/validators/videos/video-playlists.ts@@ -263,7 +263,7 @@ export const videoPlaylistsAddVideoValidator = [if (areValidationErrors(req, res)) returnif (!await doesVideoPlaylistExist({ id: req.params.playlistId, req, res, fetchType: 'all' })) return- if (!await doesVideoExist(req.body.videoId, res, 'only-video-and-blacklist')) return+ if (!await doesVideoExist(req.body.videoId, res, 'with-thumbnails')) returnconst videoPlaylist = getPlaylist(res)diff --git a/server/core/middlewares/validators/videos/video-rates.ts b/server/core/middlewares/validators/videos/video-rates.tsindex 4f49dd206d..837ab9f623 100644--- a/server/core/middlewares/validators/videos/video-rates.ts+++ b/server/core/middlewares/validators/videos/video-rates.ts@@ -20,7 +20,7 @@ const videoUpdateRateValidator = [if (areValidationErrors(req, res)) returnif (!await doesVideoExist(req.params.id, res)) return- if (!await checkCanSeeVideo({ req, res, paramId: req.params.id, video: res.locals.videoAll })) return+ if (!await checkCanSeeVideo({ req, res, paramId: req.params.id, video: res.locals.videoFull })) returnreturn next()}diff --git a/server/core/middlewares/validators/videos/video-shares.ts b/server/core/middlewares/validators/videos/video-shares.tsindex 075745d1c8..8a0874ecc1 100644--- a/server/core/middlewares/validators/videos/video-shares.ts+++ b/server/core/middlewares/validators/videos/video-shares.ts@@ -14,9 +14,9 @@ export const videosShareValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.id, res)) return+ if (!await doesVideoExist(req.params.id, res, 'with-blacklist')) return- const video = res.locals.videoAll+ const video = res.locals.videoWithBlacklistif (!canVideoBeFederated(video)) res.sendStatus(HttpStatusCode.NOT_FOUND_404)const share = await VideoShareModel.load(req.params.actorId, video.id)diff --git a/server/core/middlewares/validators/videos/video-source.ts b/server/core/middlewares/validators/videos/video-source.tsindex e88d27357e..5d471e7135 100644--- a/server/core/middlewares/validators/videos/video-source.ts+++ b/server/core/middlewares/validators/videos/video-source.ts@@ -1,9 +1,7 @@import { HttpStatusCode, UserRight } from '@peertube/peertube-models'-import { getVideoWithAttributes } from '@server/helpers/video.js'import { CONFIG } from '@server/initializers/config.js'import { buildUploadXFile, safeUploadXCleanup } from '@server/lib/uploadx.js'import { VideoSourceModel } from '@server/models/video/video-source.js'-import { MVideoFullLight } from '@server/types/models/index.js'import { Metadata as UploadXMetadata } from '@uploadx/core'import express from 'express'import { param } from 'express-validator'@@ -21,9 +19,9 @@ export const videoSourceGetLatestValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.id, res, 'all')) return+ if (!await doesVideoExist(req.params.id, res, 'with-rights')) return- const video = getVideoWithAttributes(res) as MVideoFullLight+ const video = res.locals.videoWithRightsconst user = res.locals.oauth.token.Userif (!await checkCanManageVideo({ user, video, right: UserRight.UPDATE_ANY_VIDEO, req, res, checkIsLocal: true, checkIsOwner: false })) {@@ -80,7 +78,7 @@ export const replaceVideoSourceResumableInitValidator = [const fileMetadata = res.locals.uploadVideoFileResumableMetadataconst files = { videofile: [ fileMetadata ] }- const channelUser = { id: res.locals.videoAll.VideoChannel.Account.userId }+ const channelUser = { id: res.locals.videoFull.VideoChannel.Account.userId }if (await commonVideoFileChecks({ req, res, channelUser, videoFileSize: fileMetadata.size, files }) === false) return@@ -131,7 +129,7 @@ async function checkCanUpdateVideoFile (options: {if (!await doesVideoExist(req.params.id, res)) return falseconst user = res.locals.oauth.token.User- const video = res.locals.videoAll+ const video = res.locals.videoFullif (!await checkCanManageVideo({ user, video, right: UserRight.UPDATE_ANY_VIDEO, req, res, checkIsLocal: true, checkIsOwner: false })) {return falsediff --git a/server/core/middlewares/validators/videos/video-stats.ts b/server/core/middlewares/validators/videos/video-stats.tsindex 3df58790a7..4f5d7ed08a 100644--- a/server/core/middlewares/validators/videos/video-stats.ts+++ b/server/core/middlewares/validators/videos/video-stats.ts@@ -1,9 +1,9 @@-import express from 'express'-import { param, query } from 'express-validator'+import { HttpStatusCode, UserRight, VideoStatsTimeserieQuery } from '@peertube/peertube-models'import { isDateValid } from '@server/helpers/custom-validators/misc.js'import { isValidStatTimeserieMetric } from '@server/helpers/custom-validators/video-stats.js'import { STATS_TIMESERIE } from '@server/initializers/constants.js'-import { HttpStatusCode, UserRight, VideoStatsTimeserieQuery } from '@peertube/peertube-models'+import express from 'express'+import { param, query } from 'express-validator'import { areValidationErrors, checkCanManageVideo, doesVideoExist, isValidVideoIdParam } from '../shared/index.js'export const videoOverallOrUserAgentStatsValidator = [@@ -32,10 +32,10 @@ export const videoRetentionStatsValidator = [if (areValidationErrors(req, res)) returnif (!await commonStatsCheck(req, res)) return- if (res.locals.videoAll.isLive) {+ if (res.locals.videoWithRights.isLive) {return res.fail({status: HttpStatusCode.BAD_REQUEST_400,- message: 'Cannot get retention stats of live video'+ message: req.t('Cannot get retention stats of live video')})}@@ -68,14 +68,14 @@ export const videoTimeseriesStatsValidator = [) {return res.fail({status: HttpStatusCode.BAD_REQUEST_400,- message: 'Both start date and end date should be defined if one of them is specified'+ message: req.t('Both start date and end date should be defined if one of them is specified')})}if (query.startDate && getIntervalByDays(query.startDate, query.endDate) > STATS_TIMESERIE.MAX_DAYS) {return res.fail({status: HttpStatusCode.BAD_REQUEST_400,- message: 'Start date and end date interval is too big'+ message: req.t('Start date and end date interval is too big')})}@@ -88,12 +88,12 @@ export const videoTimeseriesStatsValidator = [// ---------------------------------------------------------------------------async function commonStatsCheck (req: express.Request, res: express.Response) {- if (!await doesVideoExist(req.params.videoId, res, 'all')) return false+ if (!await doesVideoExist(req.params.videoId, res, 'with-rights')) return falseif (!await checkCanManageVideo({user: res.locals.oauth.token.User,- video: res.locals.videoAll,+ video: res.locals.videoWithRights,right: UserRight.SEE_ALL_VIDEOS,req,res,diff --git a/server/core/middlewares/validators/videos/video-studio.ts b/server/core/middlewares/validators/videos/video-studio.tsindex dbf9d23c2d..dd33a64b1e 100644--- a/server/core/middlewares/validators/videos/video-studio.ts+++ b/server/core/middlewares/validators/videos/video-studio.ts@@ -38,7 +38,7 @@ const videoStudioAddEditionValidator = [const body: VideoStudioCreateEdition = req.bodyconst files = req.files as Express.Multer.File[]- const video = res.locals.videoAll+ const video = res.locals.videoFullconst videoIsAudio = video.hasAudio() && !video.hasVideo()for (let i = 0; i < body.tasks.length; i++) {@@ -88,7 +88,7 @@ const videoStudioAddEditionValidator = [// Try to make an approximation of bytes added by the intro/outroconst additionalBytes = await approximateIntroOutroAdditionalSize(video, body.tasks, i => getTaskFileFromReq(files, i).path)- const channelUser = { id: res.locals.videoAll.VideoChannel.Account.userId }+ const channelUser = { id: res.locals.videoFull.VideoChannel.Account.userId }if (await checkUserQuota({ channelUser, videoFileSize: additionalBytes, req, res }) === false) return cleanUpReqFiles(req)return next()diff --git a/server/core/middlewares/validators/videos/video-token.ts b/server/core/middlewares/validators/videos/video-token.tsindex 7489137551..baae137edc 100644--- a/server/core/middlewares/validators/videos/video-token.ts+++ b/server/core/middlewares/validators/videos/video-token.ts@@ -4,7 +4,7 @@ import { exists } from '@server/helpers/custom-validators/misc.js'const videoFileTokenValidator = [(req: express.Request, res: express.Response, next: express.NextFunction) => {- const video = res.locals.onlyVideo+ const video = res.locals.videoWithBlacklistif (video.privacy !== VideoPrivacy.PASSWORD_PROTECTED && !exists(res.locals.oauth.token.User)) {return res.fail({status: HttpStatusCode.UNAUTHORIZED_401,diff --git a/server/core/middlewares/validators/videos/video-transcoding.ts b/server/core/middlewares/validators/videos/video-transcoding.tsindex b9fbd222db..777300d74a 100644--- a/server/core/middlewares/validators/videos/video-transcoding.ts+++ b/server/core/middlewares/validators/videos/video-transcoding.ts@@ -21,9 +21,9 @@ const createTranscodingValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.videoId, res, 'all')) return+ if (!await doesVideoExist(req.params.videoId, res, 'full')) return- const video = res.locals.videoAll+ const video = res.locals.videoFullconst body = req.body as VideoTranscodingCreateif (!checkVideoCanBeTranscribedOrTranscoded({ video, req, res, skipStateCheck: body.forceTranscoding === true })) returndiff --git a/server/core/middlewares/validators/videos/video-view.ts b/server/core/middlewares/validators/videos/video-view.tsindex 8f4b70d142..41bcb40969 100644--- a/server/core/middlewares/validators/videos/video-view.ts+++ b/server/core/middlewares/validators/videos/video-view.ts@@ -63,9 +63,9 @@ export const videoViewValidator = [async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res, { tags })) return- if (!await doesVideoExist(req.params.videoId, res, 'unsafe-only-immutable-attributes')) return+ if (!await doesVideoExist(req.params.videoId, res, 'unsafe-immutable-only')) return- const video = res.locals.onlyImmutableVideo+ const video = res.locals.videoImmutableconst { duration } = await getCachedVideoDuration(video.id)const currentTime = req.body.currentTimediff --git a/server/core/middlewares/validators/videos/videos.ts b/server/core/middlewares/validators/videos/videos.tsindex 99c3b85933..03268dc00c 100644--- a/server/core/middlewares/validators/videos/videos.ts+++ b/server/core/middlewares/validators/videos/videos.ts@@ -13,7 +13,7 @@ import { Redis } from '@server/lib/redis.js'import { buildUploadXFile, safeUploadXCleanup } from '@server/lib/uploadx.js'import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership.js'import { ExpressPromiseHandler } from '@server/types/express-handler.js'-import { MVideoFullLight } from '@server/types/models/index.js'+import { MVideoFull } from '@server/types/models/index.js'import express from 'express'import { body, param, query, ValidationChain } from 'express-validator'import {@@ -236,7 +236,7 @@ export const videosUpdateValidator = getCommonVideoEditAttributes().concat([if (!isValidPasswordProtectedPrivacy(req, res)) return cleanUpReqFiles(req)- const video = res.locals.videoAll+ const video = res.locals.videoFullif (exists(req.body.privacy) && video.isLive && video.privacy !== req.body.privacy && video.state !== VideoState.WAITING_FOR_LIVE) {return res.fail({ message: req.t('Cannot update privacy of a live that has already started') })}@@ -308,8 +308,8 @@ export async function checkVideoFollowConstraints (req: express.Request, res: ex})}-type FetchType = Extract<VideoLoadType, 'for-api' | 'all' | 'only-video-and-blacklist' | 'unsafe-only-immutable-attributes'>-export const videosCustomGetValidator = (fetchType: FetchType) => {+type FetchType = Extract<VideoLoadType, 'for-api' | 'full' | 'with-blacklist' | 'unsafe-immutable-only'>+export const videoGetValidatorFactory = (fetchType: FetchType) => {return [isValidVideoIdParam('id'),@@ -320,9 +320,9 @@ export const videosCustomGetValidator = (fetchType: FetchType) => {if (!await doesVideoExist(req.params.id, res, fetchType)) return// Controllers does not need to check video rights- if (fetchType === 'unsafe-only-immutable-attributes') return next()+ if (fetchType === 'unsafe-immutable-only') return next()- const video = getVideoWithAttributes(res) as MVideoFullLight+ const video = getVideoWithAttributes(res) as MVideoFullif (!await checkCanSeeVideo({ req, res, video, paramId: req.params.id })) return@@ -331,9 +331,7 @@ export const videosCustomGetValidator = (fetchType: FetchType) => {]}-export const videosGetValidator = videosCustomGetValidator('all')--export const videoFileMetadataGetValidator = getCommonVideoEditAttributes().concat([+export const videoFileMetadataGetValidator = [isValidVideoIdParam('id'),param('videoFileId')@@ -345,14 +343,14 @@ export const videoFileMetadataGetValidator = getCommonVideoEditAttributes().concreturn next()}-])+]export const videosDownloadValidator = [isValidVideoIdParam('id'),async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return- if (!await doesVideoExist(req.params.id, res, 'all')) return+ if (!await doesVideoExist(req.params.id, res, 'full')) returnconst video = getVideoWithAttributes(res)@@ -386,7 +384,7 @@ export const videosRemoveValidator = [if (!await checkCanManageVideo({user: res.locals.oauth.token.User,- video: res.locals.videoAll,+ video: res.locals.videoFull,right: UserRight.REMOVE_ANY_VIDEO,req,res,diff --git a/server/core/models/video/sql/video/shared/abstract-video-query-builder.ts b/server/core/models/video/sql/video/shared/abstract-video-query-builder.tsindex d61db21243..e092240fd0 100644--- a/server/core/models/video/sql/video/shared/abstract-video-query-builder.ts+++ b/server/core/models/video/sql/video/shared/abstract-video-query-builder.ts@@ -87,18 +87,6 @@ export class AbstractVideoQueryBuilder extends AbstractRunQuery {}}- protected includeOwnerUser () {- this.addJoin('INNER JOIN "videoChannel" AS "VideoChannel" ON "video"."channelId" = "VideoChannel"."id"')- this.addJoin('INNER JOIN "account" AS "VideoChannel->Account" ON "VideoChannel"."accountId" = "VideoChannel->Account"."id"')-- this.attributes = {- ...this.attributes,-- ...this.buildAttributesObject('VideoChannel', this.tables.getChannelAttributes()),- ...this.buildAttributesObject('VideoChannel->Account', this.tables.getUserAccountAttributes())- }- }-protected includeThumbnails () {this.addJoin('LEFT OUTER JOIN "thumbnail" AS "Thumbnails" ON "video"."id" = "Thumbnails"."videoId"')diff --git a/server/core/models/video/sql/video/video-model-get-query-builder.ts b/server/core/models/video/sql/video/video-model-get-query-builder.tsindex 4e8b0e8348..f11a6a15f1 100644--- a/server/core/models/video/sql/video/video-model-get-query-builder.ts+++ b/server/core/models/video/sql/video/video-model-get-query-builder.ts@@ -12,13 +12,14 @@ import { VideoTableAttributes } from './shared/video-table-attributes.js'export type GetType =| 'api'| 'full'+ | 'account-blacklist'| 'account-blacklist-files'| 'account'| 'all-files'| 'thumbnails'- | 'thumbnails-blacklist'+ | 'blacklist'| 'id'- | 'blacklist-rights'+ | 'video'| 'seo'const videoFilesInclude = new Set<GetType>([ 'api', 'full', 'account-blacklist-files', 'all-files' ])@@ -29,15 +30,14 @@ const liveInclude = new Set<GetType>([ 'api', 'full' ])const scheduleUpdateInclude = new Set<GetType>([ 'api', 'full' ])const tagsInclude = new Set<GetType>([ 'api', 'full', 'seo' ])const userHistoryInclude = new Set<GetType>([ 'api', 'full' ])-const accountInclude = new Set<GetType>([ 'api', 'full', 'account', 'account-blacklist-files', 'seo' ])-const ownerUserInclude = new Set<GetType>([ 'blacklist-rights' ])+const accountInclude = new Set<GetType>([ 'api', 'full', 'account', 'account-blacklist', 'account-blacklist-files', 'seo' ])const blacklistedInclude = new Set<GetType>(['api','full',+ 'account-blacklist','account-blacklist-files',- 'thumbnails-blacklist',- 'blacklist-rights',+ 'blacklist','seo'])@@ -47,7 +47,6 @@ const thumbnailsInclude = new Set<GetType>(['account-blacklist-files','all-files','thumbnails',- 'thumbnails-blacklist','seo'])@@ -167,10 +166,6 @@ export class VideosModelGetQuerySubBuilder extends AbstractVideoQueryBuilder {this.includeUserHistory(options.userId)}- if (ownerUserInclude.has(options.type)) {- this.includeOwnerUser()- }-if (trackersInclude.has(options.type)) {this.includeTrackers()}diff --git a/server/core/models/video/video.ts b/server/core/models/video/video.tsindex b74e5a973a..610bd9e2de 100644--- a/server/core/models/video/video.ts+++ b/server/core/models/video/video.ts@@ -101,15 +101,16 @@ import {MVideoFileVideo,MVideoFormattable,MVideoFormattableDetails,- MVideoFullLight,+ MVideoFull,MVideoId,MVideoImmutable,MVideoOwned,MVideoSeo,- MVideoThumbnail,- MVideoThumbnailBlacklist,+ MVideoThumbnails,MVideoWithAllFiles,+ MVideoWithBlacklist,MVideoWithFile,+ MVideoWithRights,type MVideo,type MVideoAccountLight} from '../../types/models/index.js'@@ -1348,28 +1349,28 @@ export class VideoModel extends SequelizeModel<VideoModel> {return VideoModel.count(options)}- static load (id: number | string, transaction?: Transaction): Promise<MVideoThumbnail> {+ static load (id: number | string, transaction?: Transaction): Promise<MVideo> {const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)- return queryBuilder.queryVideo({ id, transaction, type: 'thumbnails' })+ return queryBuilder.queryVideo({ id, transaction, type: 'video' })}- static loadWithBlacklist (id: number | string, transaction?: Transaction): Promise<MVideoThumbnailBlacklist> {+ static loadWithThumbnails (id: number | string, transaction?: Transaction): Promise<MVideoThumbnails> {const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)- return queryBuilder.queryVideo({ id, transaction, type: 'thumbnails-blacklist' })+ return queryBuilder.queryVideo({ id, transaction, type: 'thumbnails' })}- static loadForSEO (id: number | string, transaction?: Transaction): Promise<MVideoSeo> {+ static loadWithBlacklist (id: number | string, transaction?: Transaction): Promise<MVideoWithBlacklist> {const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)- return queryBuilder.queryVideo({ id, transaction, type: 'seo' })+ return queryBuilder.queryVideo({ id, transaction, type: 'blacklist' })}- static loadAndPopulateAccountAndFiles (id: number | string, transaction?: Transaction): Promise<MVideoAccountLightBlacklistAllFiles> {+ static loadForSEO (id: number | string, transaction?: Transaction): Promise<MVideoSeo> {const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)- return queryBuilder.queryVideo({ id, transaction, type: 'account-blacklist-files' })+ return queryBuilder.queryVideo({ id, transaction, type: 'seo' })}static loadImmutableAttributes (id: number | string, t?: Transaction): Promise<MVideoImmutable> {@@ -1422,16 +1423,16 @@ export class VideoModel extends SequelizeModel<VideoModel> {return queryBuilder.queryVideo({ id, transaction, type: 'all-files', logging })}- static loadByUrl (url: string, transaction?: Transaction): Promise<MVideoThumbnail> {+ static loadByUrl (url: string, transaction?: Transaction): Promise<MVideoThumbnails> {const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)return queryBuilder.queryVideo({ url, transaction, type: 'thumbnails' })}- static loadByUrlWithBlacklist (url: string, transaction?: Transaction): Promise<MVideoThumbnailBlacklist> {+ static loadByUrlWithBlacklist (url: string, transaction?: Transaction): Promise<MVideoWithBlacklist> {const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)- return queryBuilder.queryVideo({ url, transaction, type: 'thumbnails-blacklist' })+ return queryBuilder.queryVideo({ url, transaction, type: 'blacklist' })}static loadByUrlAndPopulateAccount (url: string, transaction?: Transaction): Promise<MVideoAccountLight> {@@ -1446,12 +1447,18 @@ export class VideoModel extends SequelizeModel<VideoModel> {return queryBuilder.queryVideo({ url, transaction, type: 'account-blacklist-files' })}- static loadFull (id: number | string, t?: Transaction, userId?: number): Promise<MVideoFullLight> {+ static loadFull (id: number | string, t?: Transaction, userId?: number): Promise<MVideoFull> {const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)return queryBuilder.queryVideo({ id, transaction: t, type: 'full', userId })}+ static loadWithRights (id: number | string, t?: Transaction, userId?: number): Promise<MVideoWithRights> {+ const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)++ return queryBuilder.queryVideo({ id, transaction: t, type: 'account-blacklist', userId })+ }+static loadForGetAPI (parameters: {id: number | stringtransaction?: Transaction@@ -1941,14 +1948,14 @@ export class VideoModel extends SequelizeModel<VideoModel> {// ---------------------------------------------------------------------------- getBestThumbnail (this: Pick<MVideoThumbnail, 'Thumbnails' | 'filterThumbnails'>, ratio: ThumbnailAspectRatio, maxWidth?: number) {+ getBestThumbnail (this: Pick<MVideoThumbnails, 'Thumbnails' | 'filterThumbnails'>, ratio: ThumbnailAspectRatio, maxWidth?: number) {if (!this.Thumbnails || this.Thumbnails.length === 0) return undefinedreturn maxBy(this.filterThumbnails(ratio, maxWidth), 'width')}getBestThumbnailStaticPath (- this: Pick<MVideoThumbnail, 'Thumbnails' | 'filterThumbnails' | 'getBestThumbnail'>,+ this: Pick<MVideoThumbnails, 'Thumbnails' | 'filterThumbnails' | 'getBestThumbnail'>,ratio: ThumbnailAspectRatio,maxWidth?: number) {@@ -1958,14 +1965,14 @@ export class VideoModel extends SequelizeModel<VideoModel> {return thumbnail.getFileStaticPath()}- getSmallestThumbnail (this: Pick<MVideoThumbnail, 'Thumbnails' | 'filterThumbnails'>, ratio: ThumbnailAspectRatio) {+ getSmallestThumbnail (this: Pick<MVideoThumbnails, 'Thumbnails' | 'filterThumbnails'>, ratio: ThumbnailAspectRatio) {if (!this.Thumbnails || this.Thumbnails.length === 0) return undefinedreturn minBy(this.filterThumbnails(ratio), 'width')}getSmallestThumbnailStaticPath (- this: Pick<MVideoThumbnail, 'Thumbnails' | 'filterThumbnails' | 'getSmallestThumbnail'>,+ this: Pick<MVideoThumbnails, 'Thumbnails' | 'filterThumbnails' | 'getSmallestThumbnail'>,ratio: ThumbnailAspectRatio) {const thumbnail = this.getSmallestThumbnail(ratio)@@ -1974,7 +1981,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {return thumbnail.getFileStaticPath()}- filterThumbnails (this: Pick<MVideoThumbnail, 'Thumbnails'>, ratio: ThumbnailAspectRatio, maxWidth?: number) {+ filterThumbnails (this: Pick<MVideoThumbnails, 'Thumbnails'>, ratio: ThumbnailAspectRatio, maxWidth?: number) {if (!this.Thumbnails) return []return this.Thumbnails.filter(t => t.aspectRatio === ratio && (!maxWidth || t.width <= maxWidth))diff --git a/server/core/types/express.d.ts b/server/core/types/express.d.tsindex b41c4fe8ca..0e285e137a 100644--- a/server/core/types/express.d.ts+++ b/server/core/types/express.d.ts@@ -32,7 +32,9 @@ import {MVideoPassword,MVideoPlaylistFull,MVideoPlaylistFullSummary,- MVideoThumbnailBlacklist,+ MVideoThumbnails,+ MVideoWithBlacklist,+ MVideoWithRights,MWatchedWordsList} from '@server/types/models/index.js'import { MOAuthToken, MOAuthTokenUser } from '@server/types/models/oauth/oauth-token.js'@@ -55,7 +57,7 @@ import {MUserDefault,MVideoBlacklist,MVideoCaptionVideo,- MVideoFullLight,+ MVideoFull,MVideoRedundancyVideo,MVideoShareActor} from './models/index.js'@@ -147,9 +149,11 @@ declare module 'express' {ffprobe?: FfprobeDatavideoAPI?: MVideoFormattableDetails- videoAll?: MVideoFullLight- onlyImmutableVideo?: MVideoImmutable- onlyVideo?: MVideoThumbnailBlacklist+ videoFull?: MVideoFull+ videoImmutable?: MVideoImmutable+ videoWithBlacklist?: MVideoWithBlacklist+ videoWithRights?: MVideoWithRights+ videoThumbnails?: MVideoThumbnailsvideoId?: MVideoIdvideoLive?: MVideoLiveWithSettingSchedulesdiff --git a/server/core/types/models/video/video-import.ts b/server/core/types/models/video/video-import.tsindex 0c1263d05a..d783b078d3 100644--- a/server/core/types/models/video/video-import.ts+++ b/server/core/types/models/video/video-import.ts@@ -1,7 +1,7 @@import { VideoImportModel } from '@server/models/video/video-import.js'import { PickWith, PickWithOpt } from '@peertube/peertube-typescript-utils'import { MUser } from '../user/user.js'-import { MVideo, MVideoAccountLight, MVideoFormattable, MVideoTag, MVideoThumbnail, MVideoWithFile } from './video.js'+import { MVideo, MVideoAccountLight, MVideoFormattable, MVideoTag, MVideoThumbnails, MVideoWithFile } from './video.js'type Use<K extends keyof VideoImportModel, M> = PickWith<VideoImportModel, K, M>@@ -15,7 +15,7 @@ export type MVideoImportVideo =// ############################################################################-type VideoAssociation = MVideoTag & MVideoAccountLight & MVideoThumbnail+type VideoAssociation = MVideoTag & MVideoAccountLight & MVideoThumbnailsexport type MVideoImportDefault =& MVideoImportdiff --git a/server/core/types/models/video/video-playlist-element.ts b/server/core/types/models/video/video-playlist-element.tsindex 4439e2f6bc..e52753c9e4 100644--- a/server/core/types/models/video/video-playlist-element.ts+++ b/server/core/types/models/video/video-playlist-element.ts@@ -1,6 +1,6 @@import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element.js'import { PickWith } from '@peertube/peertube-typescript-utils'-import { MVideoFormattable, MVideoThumbnail, MVideoUrl } from './video.js'+import { MVideoFormattable, MVideoThumbnails, MVideoUrl } from './video.js'import { MVideoPlaylistPrivacy } from './video-playlist.js'type Use<K extends keyof VideoPlaylistElementModel, M> = PickWith<VideoPlaylistElementModel, K, M>@@ -19,7 +19,7 @@ export type MVideoPlaylistElementLight = Pick<MVideoPlaylistElement, 'id' | 'videxport type MVideoPlaylistElementVideoThumbnail =& MVideoPlaylistElement- & Use<'Video', MVideoThumbnail>+ & Use<'Video', MVideoThumbnails>export type MVideoPlaylistElementVideoUrl =& MVideoPlaylistElementdiff --git a/server/core/types/models/video/video.ts b/server/core/types/models/video/video.tsindex 2670636785..471604f960 100644--- a/server/core/types/models/video/video.ts+++ b/server/core/types/models/video/video.ts@@ -16,8 +16,7 @@ import {MChannelAccountSummaryFormattable,MChannelActor,MChannelFormattable,- MChannelHostOnly,- MChannelUserId+ MChannelHostOnly} from './video-channel.js'import { MVideoFile } from './video-file.js'import { MVideoLiveWithSchedules } from './video-live.js'@@ -84,21 +83,12 @@ export type MVideoWithFile =& Use<'VideoFiles', MVideoFile[]>& Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>-export type MVideoThumbnail =+export type MVideoThumbnails =& MVideo& Use<'Thumbnails', MThumbnail[]>-export type MVideoIdThumbnail =- & MVideoId- & Use<'Thumbnails', MThumbnail[]>--export type MVideoWithFileThumbnail =- & MVideoWithFile- & Use<'Thumbnails', MThumbnail[]>--export type MVideoThumbnailBlacklist =+export type MVideoWithBlacklist =& MVideo- & Use<'Thumbnails', MThumbnail[]>& Use<'VideoBlacklist', MVideoBlacklistLight>export type MVideoTag =@@ -148,7 +138,7 @@ export type MVideoAccountLight =export type MVideoWithRights =& MVideo& Use<'VideoBlacklist', MVideoBlacklistLight>- & Use<'VideoChannel', MChannelUserId>+ & Use<'VideoChannel', MChannelAccountLight>// ############################################################################@@ -193,7 +183,7 @@ export type MVideoWithHost =& MVideo& Use<'VideoChannel', MChannelHostOnly>-export type MVideoFullLight =+export type MVideoFull =& MVideo& Use<'Thumbnails', MThumbnail[]>& Use<'VideoBlacklist', MVideoBlacklistLight>@@ -251,7 +241,7 @@ export type MVideoForRedundancyAPI =// Format for API or AP objectexport type MVideoFormattable =- & MVideoThumbnail+ & MVideoThumbnails& PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]>& Use<'VideoChannel', MChannelAccountSummaryFormattable>& PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>>diff --git a/server/core/types/plugins/register-server-option.model.ts b/server/core/types/plugins/register-server-option.model.tsindex ac4dd4096b..930e055082 100644--- a/server/core/types/plugins/register-server-option.model.ts+++ b/server/core/types/plugins/register-server-option.model.ts@@ -16,7 +16,7 @@ import {VideoBlacklistCreate} from '@peertube/peertube-models'import { ActorModel } from '@server/models/actor/actor.js'-import { MUserDefault, MVideo, MVideoThumbnail, MVideoWithAllFiles, UserNotificationModelForApi } from '../models/index.js'+import { MUserDefault, MVideo, MVideoThumbnails, MVideoWithAllFiles, UserNotificationModelForApi } from '../models/index.js'import {RegisterServerAuthExternalOptions,RegisterServerAuthExternalResult,@@ -32,9 +32,9 @@ export type PeerTubeHelpers = {}videos: {- loadByUrl: (url: string) => Promise<MVideoThumbnail>+ loadByUrl: (url: string) => Promise<MVideoThumbnails>loadByIdOrUUIDWithFiles: (id: number | string) => Promise<MVideoWithAllFiles>- loadByIdOrUUID: (id: number | string) => Promise<MVideoThumbnail>+ loadByIdOrUUID: (id: number | string) => Promise<MVideoThumbnails>removeVideo: (videoId: number) => Promise<void>diff --git a/server/scripts/create-move-video-storage-job.ts b/server/scripts/create-move-video-storage-job.tsindex 2c4e90f8e1..2d3bbdeba9 100644--- a/server/scripts/create-move-video-storage-job.ts+++ b/server/scripts/create-move-video-storage-job.ts@@ -7,7 +7,7 @@ import { JobQueue } from '@server/lib/job-queue/index.js'import { hasVideoResourcesToBeMoved } from '@server/lib/move-storage/shared/move-video.js'import { moveToExternalStorageState, moveToFileSystemState } from '@server/lib/video-state.js'import { VideoModel } from '@server/models/video/video.js'-import { MVideoFullLight } from '@server/types/models/index.js'+import { MVideoFull } from '@server/types/models/index.js'const program = createCommand().description('Move videos to another storage.')@@ -106,7 +106,7 @@ async function run () {}async function createMoveJobIfNeeded (options: {- video: MVideoFullLight+ video: MVideoFulltargetStorage: FileStorageTypehandler: () => Promise<any>diff --git a/server/scripts/migrations/peertube-5.0.ts b/server/scripts/migrations/peertube-5.0.tsindex 55808ce477..7683848f5a 100644--- a/server/scripts/migrations/peertube-5.0.ts+++ b/server/scripts/migrations/peertube-5.0.ts@@ -4,7 +4,7 @@ import { updateTorrentMetadata } from '@server/lib/webtorrent.js'import { DIRECTORIES } from '@server/initializers/constants.js'import { moveFilesIfPrivacyChanged } from '@server/lib/video-privacy.js'import { VideoModel } from '@server/models/video/video.js'-import { MVideoFullLight } from '@server/types/models/index.js'+import { MVideoFull } from '@server/types/models/index.js'import { VideoPrivacy } from '@peertube/peertube-models'import { initDatabaseModels } from '@server/initializers/database.js'@@ -55,7 +55,7 @@ async function run () {}}-async function updateTorrents (video: MVideoFullLight) {+async function updateTorrents (video: MVideoFull) {for (const file of video.VideoFiles) {await updateTorrentMetadata(video, file)