Skip to content

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.ts
index 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.videoFull
if (redirectIfNotOwned(video.url, res)) return
@@ -355,13 +355,13 @@ async function videoAnnounceController (req: express.Request, res: express.Respo
if (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.videoWithBlacklist
if (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.videoWithBlacklist
if (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.videoWithBlacklist
if (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.videoWithBlacklist
if (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.videoWithBlacklist
if (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.videoWithBlacklist
if (redirectIfNotOwned(video.url, res)) return
diff --git a/server/core/controllers/api/abuse.ts b/server/core/controllers/api/abuse.ts
index 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.videoFull
const commentInstance = res.locals.videoCommentFull
const accountInstance = res.locals.account
diff --git a/server/core/controllers/api/metrics.ts b/server/core/controllers/api/metrics.ts
index 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.ts
index 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.videoWithRights
const { videoSetting, channelSetting } = await PlayerSettingModel.loadByVideoIdOrChannelId({
channelId: video.channelId,
@@ -91,7 +91,7 @@ async function getChannelPlayerSettings (req: express.Request, res: express.Resp
async function updateVideoPlayerSettings (req: express.Request, res: express.Response) {
const body: PlayerVideoSettingsUpdate = req.body
- const video = res.locals.videoAll
+ const video = res.locals.videoFull
const 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.ts
index 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.runnerJob
const runner = runnerJob.Runner
- const video = res.locals.videoAll
+ const video = res.locals.videoFull
logger.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: expre
async function getMaxQualityVideoFile (req: express.Request, res: express.Response) {
const runnerJob = res.locals.runnerJob
const runner = runnerJob.Runner
- const video = res.locals.videoAll
+ const video = res.locals.videoFull
logger.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: MVideoFull
file: MVideoFileVideo | MVideoFileStreamingPlaylistVideo
req: express.Request
res: express.Response
@@ -130,7 +130,7 @@ async function serveVideoFile (options: {
function getMaxQualityVideoThumbnail (req: express.Request, res: express.Response) {
const runnerJob = res.locals.runnerJob
const runner = runnerJob.Runner
- const video = res.locals.videoAll
+ const video = res.locals.videoFull
logger.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.Respons
function getVideoStudioTaskFile (req: express.Request, res: express.Response) {
const runnerJob = res.locals.runnerJob
const runner = runnerJob.Runner
- const video = res.locals.videoAll
+ const video = res.locals.videoFull
const filename = req.params.filename
logger.info(
diff --git a/server/core/controllers/api/server/redundancy.ts b/server/core/controllers/api/server/redundancy.ts
index 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.Respons
async 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.ts
index 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.Resp
heldForReview: 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.ts
index 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.body
const videoPlaylist = res.locals.videoPlaylistFull
- const video = res.locals.onlyVideo
+ const video = res.locals.videoThumbnails
const 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.ts
index 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.videoWithRights
const body: VideoBlacklistCreate = req.body
await 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.videoWithRights
await unblacklistVideo(videoBlacklist, video)
diff --git a/server/core/controllers/api/videos/captions.ts b/server/core/controllers/api/videos/captions.ts
index 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 } from
import { 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.videoWithRights
const body = req.body as VideoCaptionGenerate
if (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.videoFull
const 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.videoFull
const videoCaption = res.locals.videoCaption
const hasM3U8 = !!videoCaption.m3u8Filename
diff --git a/server/core/controllers/api/videos/chapters.ts b/server/core/controllers/api/videos/chapters.ts
index 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-ac
import { 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.videoFull
await retryTransactionWrapper(() => {
return sequelizeTypescript.transaction(async t => {
diff --git a/server/core/controllers/api/videos/comment.ts b/server/core/controllers/api/videos/comment.ts
index 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.videoWithBlacklist
const user = res.locals.oauth ? res.locals.oauth.token.User : undefined
let 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.videoWithBlacklist
const user = res.locals.oauth ? res.locals.oauth.token.User : undefined
let resultList: ResultList<MCommentFormattable>
@@ -208,7 +208,7 @@ async function addVideoCommentThread (req: express.Request, res: express.Respons
const 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.Response
const 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.ts
index 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.videoWithBlacklist
const domainAllowed = video.embedPrivacyPolicy === VideoEmbedPrivacyPolicy.ALL_ALLOWED
? true
@@ -88,7 +88,7 @@ async function isVideoEmbedOnDomainAllowed (req: express.Request, res: express.R
if (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.videoFull
const body = req.body as VideoEmbedPrivacyUpdate
await VideoPasswordModel.sequelize.transaction(async (t: Transaction) => {
diff --git a/server/core/controllers/api/videos/files.ts b/server/core/controllers/api/videos/files.ts
index 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.videoFull
logger.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.videoFull
const videoFileId = +req.params.videoFileId
logger.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.videoFull
logger.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.videoFull
const videoFileId = +req.params.videoFileId
logger.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.ts
index 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.ts
index 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.videoFull
await 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.ts
index 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/video
import {
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.Respons
return 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.videoFull
const videoLive = res.locals.videoLive
await retryTransactionWrapper(() => {
diff --git a/server/core/controllers/api/videos/ownership.ts b/server/core/controllers/api/videos/ownership.ts
index 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.videoWithRights
const initiatorAccountId = res.locals.oauth.token.User.Account.id
const 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 MVideoFull
targetVideoUpdated.VideoChannel = channel
if (canVideoBeFederated(targetVideoUpdated)) {
diff --git a/server/core/controllers/api/videos/passwords.ts b/server/core/controllers/api/videos/passwords.ts
index 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.videoWithRights
const videoId = video.id
const 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.videoWithRights
const videoId = video.id
const 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.videoWithRights
const password = res.locals.videoPassword
await VideoPasswordModel.deletePassword(password.id)
diff --git a/server/core/controllers/api/videos/rate.ts b/server/core/controllers/api/videos/rate.ts
index 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.videoFull
await userRateVideo({
account: user.Account,
diff --git a/server/core/controllers/api/videos/source.ts b/server/core/controllers/api/videos/source.ts
index 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.videoWithRights
await video.removeOriginalFile(videoSource)
@@ -96,10 +96,10 @@ async function replaceVideoSourceResumable (req: express.Request, res: express.R
const 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.R
const 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.VideoFiles
oldStreamingPlaylists = 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.ts
index 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.videoWithRights
const query = req.query as VideoStatsOverallQuery
const 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.videoWithRights
const query = req.query as VideoStatsUserAgentQuery
const 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.videoWithRights
const 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.videoWithRights
const metric = req.params.metric as VideoStatsTimeserieMetric
const query = req.query as VideoStatsTimeserieQuery
diff --git a/server/core/controllers/api/videos/storyboard.ts b/server/core/controllers/api/videos/storyboard.ts
index 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.ts
index 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.videoFull
video.state = VideoState.TO_EDIT
await video.save()
diff --git a/server/core/controllers/api/videos/token.ts b/server/core/controllers/api/videos/token.ts
index 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.videoWithBlacklist
const 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.ts
index 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.videoFull
logger.info('Creating %s transcoding job for %s.', req.body.transcodingType, video.url, lTags())
const body: VideoTranscodingCreate = req.body
diff --git a/server/core/controllers/api/videos/update.ts b/server/core/controllers/api/videos/update.ts
index 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.videoFull
const oldVideoAuditView = new VideoAuditView(videoFromReq.toFormattedDetailsJSON())
const body: VideoUpdate = req.body
const 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 MVideoFull
if (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 federation
async function updateVideoPrivacy (options: {
- videoInstance: MVideoFullLight
+ videoInstance: MVideoFull
videoInfoToUpdate: VideoUpdate
hadPrivacyForFederation: boolean
transaction: 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.ts
index 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.videoImmutable
const body = req.body as VideoView
const ip = req.ip
diff --git a/server/core/controllers/download.ts b/server/core/controllers/download.ts
index 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.videoFull
const 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.videoFull
const 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.videoFull
const filesToSelect = req.query.videoFileIds
const 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 undefined
diff --git a/server/core/controllers/feeds/comment-feeds.ts b/server/core/controllers/feeds/comment-feeds.ts
index 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.videoWithRights
const account = res.locals.account
const videoChannel = res.locals.videoChannel
diff --git a/server/core/controllers/feeds/shared/common-feed-utils.ts b/server/core/controllers/feeds/shared/common-feed-utils.ts
index 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.Respons
export async function buildFeedMetadata (options: {
videoChannel?: MChannelBannerAccountDefault
account?: MAccountDefault
- video?: MVideoFullLight
+ video?: MVideo
}) {
const { video, videoChannel, account } = options
diff --git a/server/core/controllers/feeds/video-podcast-feeds.ts b/server/core/controllers/feeds/video-podcast-feeds.ts
index 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.ts
index 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.videoWithBlacklist
const filename = req.params.filename
const reinjectVideoFileToken = filename.endsWith('.m3u8') && doReinjectVideoFileToken(req)
diff --git a/server/core/controllers/services.ts b/server/core/controllers/services.ts
index 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.ts
index 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.ts
index 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: MVide
try {
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.ts
index 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: MActorSignatu
if (!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()) return
if (!canVideoBeFederated(onlyVideo)) {
diff --git a/server/core/lib/activitypub/process/process-like.ts b/server/core/lib/activitypub/process/process-like.ts
index 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: ActivityLik
const byAccount = byActor.Account
if (!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()) return
if (!canVideoBeFederated(onlyVideo)) {
diff --git a/server/core/lib/activitypub/process/process-update.ts b/server/core/lib/activitypub/process/process-update.ts
index 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 | string
const { 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 update
if (created) return
diff --git a/server/core/lib/activitypub/process/process-view.ts b/server/core/lib/activitypub/process/process-view.ts
index 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: MActorSignatu
const { 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.ts
index 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)) return
const byActor = video.VideoChannel.Account.Actor
diff --git a/server/core/lib/activitypub/video-rates.ts b/server/core/lib/activitypub/video-rates.ts
index 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: Transaction
diff --git a/server/core/lib/activitypub/videos/get.ts b/server/core/lib/activitypub/videos/get.ts
index 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: APObjectId
syncParam?: SyncParam
- fetchType?: 'all'
+ fetchType?: 'full'
allowRefresh?: boolean
}
type GetVideoParamImmutable = {
videoObject: APObjectId
syncParam?: SyncParam
- fetchType: 'unsafe-only-immutable-attributes'
+ fetchType: 'unsafe-immutable-only'
allowRefresh: false
}
type GetVideoParamOther = {
videoObject: APObjectId
syncParam?: SyncParam
- fetchType?: 'all' | 'only-video-and-blacklist'
+ fetchType?: 'full' | 'with-blacklist'
allowRefresh?: boolean
}
@@ -43,13 +38,13 @@ export function getOrCreateAPVideo (options: GetVideoParamAll): GetVideoResult<M
export 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 params
const 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 MVideoThumbnails
if (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): GetVideoRes
export 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.ts
index 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: MVideoThumbnails
fetchedType: VideoLoadByUrlType
syncParam: 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.ts
index 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.icon
if (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') return
const { 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') return
await 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.ts
index 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 = channelActor
const 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 MVideoThumbnails
const { autoBlacklisted, videoCreated } = await sequelizeTypescript.transaction(async t => {
- const videoCreated = await video.save({ transaction: t }) as MVideoFullLight
+ const videoCreated = await video.save({ transaction: t }) as MVideoFull
videoCreated.VideoChannel = channel
await this.setThumbnails(videoCreated, t)
diff --git a/server/core/lib/activitypub/videos/updater.ts b/server/core/lib/activitypub/videos/updater.ts
index 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 change
this.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) return
if (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.ts
index 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: MAccountDefault
if (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.ts
index 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.ts
index 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) return
Notifier.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.ts
index 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.ts
index 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: MVideoFull
videoFile: MVideoFile
user: MUserId
diff --git a/server/core/lib/job-queue/handlers/video-live-ending.ts b/server/core/lib/job-queue/handlers/video-live-ending.ts
index 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: MVideoThumbnails
liveSession: MVideoLiveSession
publishedAt: string
replayDirectory: string
@@ -218,8 +217,8 @@ async function saveReplayToExternalVideo (options: {
}
async function copyOrRegenerateThumbnails (options: {
- liveVideo: MVideoThumbnail
- replayVideo: MVideoWithFileThumbnail
+ liveVideo: MVideoThumbnails
+ replayVideo: MVideoWithAllFiles
}) {
const { liveVideo, replayVideo } = options
diff --git a/server/core/lib/job-queue/handlers/video-studio-edition.ts b/server/core/lib/job-queue/handlers/video-studio-edition.ts
index 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.file
diff --git a/server/core/lib/job-queue/handlers/video-transcoding.ts b/server/core/lib/job-queue/handlers/video-transcoding.ts
index 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: MergeAudioTransco
await 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: MVideoFull
try {
video = await VideoModel.loadFull(videoArg.uuid)
diff --git a/server/core/lib/local-video-creator.ts b/server/core/lib/local-video-creator.ts
index 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-schedule
import { 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: MChannelAccountLight
private readonly videoAttributeResultHook: VideoAttributeHookFilter
- private video: MVideoFullLight
+ private video: MVideoFull
private videoFile: MVideoFile
private 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 MVideoFull
this.video.VideoChannel = this.channel
this.video.url = getLocalVideoActivityPubUrl(this.video)
diff --git a/server/core/lib/model-loaders/video.ts b/server/core/lib/model-loaders/video.ts
index 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 VideoLoadType
diff --git a/server/core/lib/notifier/notifier.ts b/server/core/lib/notifier/notifier.ts
index 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.publicationAfterTranscoding
logger.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.publicationAfterScheduleUpdate
logger.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.publicationAfterAutoUnblacklist
logger.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.unblacklist
logger.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.videoStudioEditionFinished
logger.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.ts
index 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: MUserDefault
async 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.ts
index 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: MUserDefault
async 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.ts
index 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: MUserDefault
async prepare () {
diff --git a/server/core/lib/plugins/plugin-helpers-builder.ts b/server/core/lib/plugins/plugin-helpers-builder.ts
index 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.ts
index 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: UserVideoRateType
account: MAccountUrl & MAccountId
- video: MVideoFullLight
+ video: MVideoFull
}) {
const { account, rateType, video } = options
diff --git a/server/core/lib/runners/job-handlers/shared/utils.ts b/server/core/lib/runners/job-handlers/shared/utils.ts
index 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: MVideoFull
videoFilePath: string
privatePayload: RunnerJobVODWebVideoTranscodingPrivatePayload | RunnerJobVODAudioMergeTranscodingPrivatePayload
wasAudioFile: boolean
diff --git a/server/core/lib/schedulers/videos-redundancy-scheduler.ts b/server/core/lib/schedulers/videos-redundancy-scheduler.ts
index 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.ts
index 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: MVideoThumbnails
automaticallyGenerated: boolean
keepOriginal?: boolean // default to false
}) {
@@ -123,7 +123,7 @@ export async function createLocalVideoThumbnailsFromImage (options: {
function _createLocalVideoThumbnailFromImage (options: {
inputPath: string
- video: MVideoThumbnail
+ video: MVideoThumbnails
automaticallyGenerated: boolean
size: ImageSize
keepOriginal: 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: MVideoThumbnails
videoFile: MVideoFile
ffprobe: 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: MVideoThumbnails
size: ImageSize
}) {
const { downloadUrl, video, size } = options
@@ -250,7 +250,7 @@ function _createLocalVideoThumbnailFromUrl (options: {
export function updateRemoteVideoThumbnail (options: {
fileUrl: string
- video: MVideoThumbnail
+ video: MVideoThumbnails
size: ImageSize
}) {
const { fileUrl, video, size } = options
@@ -350,7 +350,7 @@ function buildMetadataFromPlaylist (options: {
}
function buildMetadataFromVideo (options: {
- video: MVideoThumbnail
+ video: MVideoThumbnails
size: ImageSize
extension: string
}) {
diff --git a/server/core/lib/transcoding/create-transcoding-job.ts b/server/core/lib/transcoding/create-transcoding-job.ts
index 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: MVideoFull
videoFile: MVideoFile
isNewVideo: boolean
user: MUserId
@@ -15,7 +15,7 @@ export function createOptimizeOrMergeAudioJobs (options: {
export function createTranscodingJobs (options: {
transcodingType: 'hls' | 'web-video'
- video: MVideoFullLight
+ video: MVideoFull
resolutions: number[]
isNewVideo: boolean
user: MUserId
diff --git a/server/core/lib/transcoding/shared/job-builders/abstract-job-builder.ts b/server/core/lib/transcoding/shared/job-builders/abstract-job-builder.ts
index 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: MVideoFull
videoFile: MVideoFile
isNewVideo: boolean
user: MUserId
@@ -136,7 +136,7 @@ export abstract class AbstractJobBuilder<P extends { transcodingPriority: Transc
async createTranscodingJobs (options: {
transcodingType: 'hls' | 'web-video'
- video: MVideoFullLight
+ video: MVideoFull
resolutions: number[]
isNewVideo: boolean
user: MUserId | null
@@ -213,7 +213,7 @@ export abstract class AbstractJobBuilder<P extends { transcodingPriority: Transc
}
private async buildLowerResolutionJobPayloads (options: {
- video: MVideoFullLight
+ video: MVideoFull
inputVideoResolution: number
inputVideoFPS: number
inputStreams: VideoFileStreamType[]
@@ -315,7 +315,7 @@ export abstract class AbstractJobBuilder<P extends { transcodingPriority: Transc
// ---------------------------------------------------------------------------
protected abstract createJobs (options: {
- video: MVideoFullLight
+ video: MVideoFull
payloads: {
parent: P
@@ -328,7 +328,7 @@ export abstract class AbstractJobBuilder<P extends { transcodingPriority: Transc
}): Promise<void>
protected abstract buildMergeAudioPayload (options: {
- video: MVideoFullLight
+ video: MVideoFull
inputFile: MVideoFile
isNewVideo: boolean
resolution: number
@@ -339,7 +339,7 @@ export abstract class AbstractJobBuilder<P extends { transcodingPriority: Transc
}): P
protected abstract buildOptimizePayload (options: {
- video: MVideoFullLight
+ video: MVideoFull
isNewVideo: boolean
inputFile: MVideoFile
resolution: number
@@ -350,7 +350,7 @@ export abstract class AbstractJobBuilder<P extends { transcodingPriority: Transc
}): P
protected abstract buildHLSJobPayload (options: {
- video: MVideoFullLight
+ video: MVideoFull
resolution: number
fps: number
isNewVideo: boolean
@@ -366,7 +366,7 @@ export abstract class AbstractJobBuilder<P extends { transcodingPriority: Transc
}): P
protected abstract buildWebVideoJobPayload (options: {
- video: MVideoFullLight
+ video: MVideoFull
resolution: number
fps: number
isNewVideo: boolean
diff --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.ts
index 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: MVideoFull
resolution: number
fps: number
isNewVideo: boolean
@@ -129,7 +129,7 @@ export class TranscodingRunnerJobBuilder extends AbstractJobBuilder<FullPayload>
}
protected buildWebVideoJobPayload (options: {
- video: MVideoFullLight
+ video: MVideoFull
resolution: number
fps: number
isNewVideo: boolean
@@ -159,7 +159,7 @@ export class TranscodingRunnerJobBuilder extends AbstractJobBuilder<FullPayload>
}
protected buildMergeAudioPayload (options: {
- video: MVideoFullLight
+ video: MVideoFull
inputFile: MVideoFile
isNewVideo: boolean
fps: number
@@ -190,7 +190,7 @@ export class TranscodingRunnerJobBuilder extends AbstractJobBuilder<FullPayload>
}
protected buildOptimizePayload (options: {
- video: MVideoFullLight
+ video: MVideoFull
inputFile: MVideoFile
isNewVideo: boolean
fps: number
diff --git a/server/core/lib/transcoding/web-transcoding.ts b/server/core/lib/transcoding/web-transcoding.ts
index 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: MVideoFull
job: 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 browsers
export async function transcodeNewWebVideoResolution (options: {
- video: MVideoFullLight
+ video: MVideoFull
resolution: number
fps: number
job: Job
@@ -123,7 +123,7 @@ export async function transcodeNewWebVideoResolution (options: {
// Merge an image with an audio file to create a video
export async function mergeAudioVideofile (options: {
- video: MVideoFullLight
+ video: MVideoFull
resolution: number
fps: number
job: Job
@@ -185,7 +185,7 @@ export async function mergeAudioVideofile (options: {
}
export async function onWebVideoFileTranscoding (options: {
- video: MVideoFullLight
+ video: MVideoFull
videoOutputPath: string
wasAudioFile?: boolean // default false
deleteWebInputVideoFile?: MVideoFile
diff --git a/server/core/lib/user-import-export/exporters/videos-exporter.ts b/server/core/lib/user-import-export/exporters/videos-exporter.ts
index 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: MVideoFull
captions: MVideoCaption[]
live: MVideoLiveWithSettingSchedules
passwords: MVideoPassword[]
@@ -371,7 +371,7 @@ export class VideosExporter extends AbstractUserExporter<VideoExportJSON> {
// ---------------------------------------------------------------------------
private async exportVideoFiles (options: {
- video: MVideoFullLight
+ video: MVideoFull
captions: MVideoCaption[]
}) {
const { video, captions } = options
@@ -445,7 +445,7 @@ export class VideosExporter extends AbstractUserExporter<VideoExportJSON> {
private async generateVideoFileReadStream (options: {
videoFile: MVideoFile
separatedAudioFile: 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.ts
index 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, Import
return { 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, Import
return captionPaths
}
- private async importPlayerSettings (video: MVideoFullLight, videoImportData: SanitizedObject) {
+ private async importPlayerSettings (video: MVideoFull, videoImportData: SanitizedObject) {
const playerSettings = videoImportData.playerSettings
if (!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) return
await VideoEmbedPrivacyDomainModel.addDomains(videoImportData.videoEmbedPrivacy.domains, video.id)
diff --git a/server/core/lib/video-blacklist.ts b/server/core/lib/video-blacklist.ts
index 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, VideoBl
import { 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, options
Notifier.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.unfederated
const videoBlacklistType = videoBlacklist.type
@@ -98,7 +100,7 @@ export async function unblacklistVideo (videoBlacklist: MVideoBlacklist, video:
// Re federate the video
if (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 send
delete 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.ts
index 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: MVideoFull
language: string
vttPath: string
lTags?: (string | number)[]
diff --git a/server/core/lib/video-comment.ts b/server/core/lib/video-comment.ts
index 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: string
inReplyToComment: MComment | null
- video: MVideoFullLight
+ video: MVideoAccountLight
user: MUserAccountId
}) {
const { user, video, text, inReplyToComment } = options
diff --git a/server/core/lib/video-download.ts b/server/core/lib/video-download.ts
index 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-op
import { 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: MVideoThumbnails
private readonly videoFiles: MVideoFile[]
private allowDirectSending = true
constructor (options: {
- video: MVideoThumbnail
+ video: MVideoThumbnails
videoFiles: MVideoFile[]
}) {
this.video = options.video
diff --git a/server/core/lib/video-jobs.ts b/server/core/lib/video-jobs.ts
index 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: MVideoFull
isNewVideoForFederation: boolean
nameChanged: boolean
diff --git a/server/core/lib/video-playlist.ts b/server/core/lib/video-playlist.ts
index 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: Transactio
return 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.ts
index 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: MVideoThumbnails
thumbnails: MThumbnail[]
videoChannel: MChannelAccountDefault
tags: 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 = videoChannel
if (thumbnails.length !== 0) {
@@ -112,7 +112,7 @@ export async function buildVideoFromImport ({ channelId, importData, importDataO
importData: YoutubeDLInfo
importDataOverride?: 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?: string
downloadUrl?: string
- video: MVideoThumbnail
+ video: MVideoThumbnails
}): Promise<MThumbnail[]> {
const { inputPath, downloadUrl, video } = options
diff --git a/server/core/lib/video-privacy.ts b/server/core/lib/video-privacy.ts
index 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 private
if (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 } = options
diff --git a/server/core/lib/video-state.ts b/server/core/lib/video-state.ts
index 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: MVideoFull
isNewVideo: boolean
transaction: Transaction
}) {
@@ -114,7 +114,7 @@ export async function moveToExternalStorageState (options: {
}
export async function moveToFileSystemState (options: {
- video: MVideoFullLight
+ video: MVideoFull
isNewVideo: boolean
transaction: Transaction
}) {
@@ -173,7 +173,7 @@ export function moveToFailedMoveToFileSystemState (video: MVideo) {
// ---------------------------------------------------------------------------
async function moveToPublishedState (options: {
- video: MVideoFullLight
+ video: MVideoFull
isNewVideo: boolean
transaction: Transaction
previousVideoState?: VideoStateType
diff --git a/server/core/lib/video-studio.ts b/server/core/lib/video-studio.ts
index 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: string
tasks: VideoStudioTaskPayload[]
- video: MVideoFullLight
+ video: MVideoFull
}) {
const { tasks, editionResultPath } = options
diff --git a/server/core/middlewares/validators/feeds.ts b/server/core/middlewares/validators/feeds.ts
index 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.ts
index 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.body
if (areValidationErrors(req, res)) return
- if (!await doesVideoExist(body.videoId, res, 'unsafe-only-immutable-attributes')) return
+ if (!await doesVideoExist(body.videoId, res, 'unsafe-immutable-only')) return
return next()
}
diff --git a/server/core/middlewares/validators/oembed.ts b/server/core/middlewares/validators/oembed.ts
index 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 = video
return 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.ts
index 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.videoWithRights
if (!await checkCanSeeVideo({ req, res, video, paramId: req.params.videoId })) return
if (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')) return
const user = res.locals.oauth.token.User
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/redundancy.ts b/server/core/middlewares/validators/redundancy.ts
index 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)) return
if (!await doesVideoExist(req.params.videoId, res)) return
- const video = res.locals.videoAll
+ const video = res.locals.videoFull
if (!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.ts
index 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')) return
const 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.ts
index 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 : undefined
const video = await loadVideo(id, fetchType, userId)
@@ -43,21 +44,33 @@ export async function doesVideoExist (id: number | string, res: Response, fetchT
res.locals.videoAPI = video as MVideoFormattableDetails
break
- case 'all':
- res.locals.videoAll = video as MVideoFullLight
+ case 'full':
+ res.locals.videoFull = video as MVideoFull
break
- case 'unsafe-only-immutable-attributes':
- res.locals.onlyImmutableVideo = video as MVideoImmutable
+ case 'unsafe-immutable-only':
+ res.locals.videoImmutable = video as MVideoImmutable
break
+ case 'none':
case 'id':
res.locals.videoId = video as MVideoId
break
- case 'only-video-and-blacklist':
- res.locals.onlyVideo = video as MVideoThumbnailBlacklist
+ case 'with-blacklist':
+ res.locals.videoWithBlacklist = video as MVideoWithBlacklist
break
+
+ 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<MVideoWithR
if (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.User
if (!user) {
diff --git a/server/core/middlewares/validators/static.ts b/server/core/middlewares/validators/static.ts
index 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, isValidVideoPasswo
type LRUValue = {
allowed: boolean
- video?: MVideoThumbnailBlacklist
+ video?: MVideoWithBlacklist
file?: 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 = video
res.locals.videoFile = file
return next()
@@ -60,7 +60,7 @@ export const ensureCanAccessVideoPrivateWebVideoFiles = [
if (result.allowed !== true) return
- res.locals.onlyVideo = result.video
+ res.locals.videoWithBlacklist = result.video
res.locals.videoFile = result.file
return 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 = video
res.locals.videoFile = file
return next()
@@ -136,7 +136,7 @@ export const ensureCanAccessPrivateVideoHLSFiles = [
if (result.allowed !== true) return
- res.locals.onlyVideo = result.video
+ res.locals.videoWithBlacklist = result.video
res.locals.videoFile = result.file
return 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.ts
index 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/c
import { 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)) return
return 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.videoWithRights
if (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)) return
return 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.ts
index 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 video
const user = res.locals.oauth.token.User
if (
!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.videoWithRights
if (!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)) return
if (!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 video
const user = res.locals.oauth.token.User
if (
!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.videoWithBlacklist
if (!await checkCanSeeVideo({ req, res, video, paramId: req.params.videoId })) return
return next()
diff --git a/server/core/middlewares/validators/videos/video-chapters.ts b/server/core/middlewares/validators/videos/video-chapters.ts
index 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)) return
if (!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.ts
index 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/vide
import { 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')) return
if (
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')) return
if (
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.videoWithRights
if (
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 })) return
return 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 })) return
return 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)) return
return 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)) return
return 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)) return
return 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)) return
if (!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)) return
if (!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.ts
index 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')) return
return 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')) return
if (
!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')) return
if (
!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.ts
index 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)) return
if (!await doesVideoExist(req.params.id, res)) return
- const video = res.locals.videoAll
+ const video = res.locals.videoFull
if (!checkLocalVideo(video, res)) return
@@ -44,7 +44,7 @@ export const videoFilesDeleteWebVideoFileValidator = [
if (areValidationErrors(req, res)) return
if (!await doesVideoExist(req.params.id, res)) return
- const video = res.locals.videoAll
+ const video = res.locals.videoFull
if (!checkLocalVideo(video, res)) return
@@ -76,7 +76,7 @@ export const videoFilesDeleteHLSValidator = [
if (areValidationErrors(req, res)) return
if (!await doesVideoExist(req.params.id, res)) return
- const video = res.locals.videoAll
+ const video = res.locals.videoFull
if (!checkLocalVideo(video, res)) return
@@ -108,7 +108,7 @@ export const videoFilesDeleteHLSFileValidator = [
if (areValidationErrors(req, res)) return
if (!await doesVideoExist(req.params.id, res)) return
- const video = res.locals.videoAll
+ const video = res.locals.videoFull
if (!checkLocalVideo(video, res)) return
diff --git a/server/core/middlewares/validators/videos/video-live.ts b/server/core/middlewares/validators/videos/video-live.ts
index 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.ts
index 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 video
if (
!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.ts
index 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')) return
if (!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')) return
if (!checkVideoIsPasswordProtected(req, res)) return
if (!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 })) return
return 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 false
if (!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.Res
if (
!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.ts
index 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)) return
if (!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')) return
const videoPlaylist = getPlaylist(res)
diff --git a/server/core/middlewares/validators/videos/video-rates.ts b/server/core/middlewares/validators/videos/video-rates.ts
index 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)) return
if (!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 })) return
return next()
}
diff --git a/server/core/middlewares/validators/videos/video-shares.ts b/server/core/middlewares/validators/videos/video-shares.ts
index 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.videoWithBlacklist
if (!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.ts
index 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.videoWithRights
const user = res.locals.oauth.token.User
if (!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.uploadVideoFileResumableMetadata
const 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 false
const user = res.locals.oauth.token.User
- const video = res.locals.videoAll
+ const video = res.locals.videoFull
if (!await checkCanManageVideo({ user, video, right: UserRight.UPDATE_ANY_VIDEO, req, res, checkIsLocal: true, checkIsOwner: false })) {
return false
diff --git a/server/core/middlewares/validators/videos/video-stats.ts b/server/core/middlewares/validators/videos/video-stats.ts
index 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)) return
if (!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 false
if (
!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.ts
index 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.body
const files = req.files as Express.Multer.File[]
- const video = res.locals.videoAll
+ const video = res.locals.videoFull
const 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/outro
const 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.ts
index 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.videoWithBlacklist
if (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.ts
index 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.videoFull
const body = req.body as VideoTranscodingCreate
if (!checkVideoCanBeTranscribedOrTranscoded({ video, req, res, skipStateCheck: body.forceTranscoding === true })) return
diff --git a/server/core/middlewares/validators/videos/video-view.ts b/server/core/middlewares/validators/videos/video-view.ts
index 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.videoImmutable
const { duration } = await getCachedVideoDuration(video.id)
const currentTime = req.body.currentTime
diff --git a/server/core/middlewares/validators/videos/videos.ts b/server/core/middlewares/validators/videos/videos.ts
index 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.videoFull
if (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 MVideoFull
if (!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().conc
return 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')) return
const 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.ts
index 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.ts
index 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.ts
index 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 | string
transaction?: 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 undefined
return 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 undefined
return 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.ts
index 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?: FfprobeData
videoAPI?: MVideoFormattableDetails
- videoAll?: MVideoFullLight
- onlyImmutableVideo?: MVideoImmutable
- onlyVideo?: MVideoThumbnailBlacklist
+ videoFull?: MVideoFull
+ videoImmutable?: MVideoImmutable
+ videoWithBlacklist?: MVideoWithBlacklist
+ videoWithRights?: MVideoWithRights
+ videoThumbnails?: MVideoThumbnails
videoId?: MVideoId
videoLive?: MVideoLiveWithSettingSchedules
diff --git a/server/core/types/models/video/video-import.ts b/server/core/types/models/video/video-import.ts
index 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 & MVideoThumbnails
export type MVideoImportDefault =
& MVideoImport
diff --git a/server/core/types/models/video/video-playlist-element.ts b/server/core/types/models/video/video-playlist-element.ts
index 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' | 'vid
export type MVideoPlaylistElementVideoThumbnail =
& MVideoPlaylistElement
- & Use<'Video', MVideoThumbnail>
+ & Use<'Video', MVideoThumbnails>
export type MVideoPlaylistElementVideoUrl =
& MVideoPlaylistElement
diff --git a/server/core/types/models/video/video.ts b/server/core/types/models/video/video.ts
index 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 object
export 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.ts
index 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.ts
index 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: MVideoFull
targetStorage: FileStorageType
handler: () => Promise<any>
diff --git a/server/scripts/migrations/peertube-5.0.ts b/server/scripts/migrations/peertube-5.0.ts
index 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)