return
}
- const video = await VideoModel.loadByUUID(options.video)
+ const video = await VideoModel.load(options.video)
if (!video) throw new Error('Video not found.')
if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.')
filePath: resolve(options.import)
}
- await JobQueue.Instance.init()
+ JobQueue.Instance.init()
await JobQueue.Instance.createJobWithPromise({ type: 'video-file-import', payload: dataInput })
console.log('Import job for video %s created.', video.uuid)
}
function doesVideoExist (keepOnlyOwned: boolean) {
return async (file: string) => {
const uuid = getUUIDFromFilename(file)
- const video = await VideoModel.loadByUUID(uuid)
+ const video = await VideoModel.load(uuid)
return video && (keepOnlyOwned === false || video.isOwned())
}
activityPubClientRouter.get('/videos/watch/:id',
executeIfActivityPub,
asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS)),
- asyncMiddleware(videosCustomGetValidator('only-video-with-rights')),
+ asyncMiddleware(videosCustomGetValidator('all')),
asyncMiddleware(videoController)
)
activityPubClientRouter.get('/videos/watch/:id/activity',
executeIfActivityPub,
- asyncMiddleware(videosCustomGetValidator('only-video-with-rights')),
+ asyncMiddleware(videosCustomGetValidator('all')),
asyncMiddleware(videoController)
)
activityPubClientRouter.get('/videos/watch/:id/announces',
}
async function videoController (req: express.Request, res: express.Response) {
- // We need more attributes
- const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(res.locals.onlyVideoWithRights.id)
+ const video = res.locals.videoAll
if (redirectIfNotOwned(video.url, res)) return
import { VideoPrivacy, VideoState } from '@shared/models'
function getVideoWithAttributes (res: Response) {
- return res.locals.videoAPI || res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights
+ return res.locals.videoAPI || res.locals.videoAll || res.locals.onlyVideo
}
function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) {
MVideoAccountLightBlacklistAllFiles,
MVideoFormattableDetails,
MVideoFullLight,
- MVideoIdThumbnail,
+ MVideoId,
MVideoImmutable,
MVideoThumbnail,
MVideoWithRights
} from '@server/types/models'
import { Hooks } from '../plugins/hooks'
-type VideoLoadType = 'for-api' | 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes'
+type VideoLoadType = 'for-api' | 'all' | 'only-video' | 'id' | 'none' | 'only-immutable-attributes'
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: 'only-immutable-attributes'): Promise<MVideoImmutable>
function loadVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise<MVideoThumbnail>
-function loadVideo (id: number | string, fetchType: 'only-video-with-rights', userId?: number): Promise<MVideoWithRights>
-function loadVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise<MVideoIdThumbnail>
+function loadVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise<MVideoId>
function loadVideo (
id: number | string,
fetchType: VideoLoadType,
userId?: number
-): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable>
+): Promise<MVideoFullLight | MVideoThumbnail | MVideoId | MVideoImmutable>
function loadVideo (
id: number | string,
fetchType: VideoLoadType,
userId?: number
-): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> {
+): Promise<MVideoFullLight | MVideoThumbnail | MVideoId | MVideoImmutable> {
if (fetchType === 'for-api') {
return Hooks.wrapPromiseFun(
if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id)
- if (fetchType === 'only-video-with-rights') return VideoModel.loadWithRights(id)
-
if (fetchType === 'only-video') return VideoModel.load(id)
if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id)
MVideoAccountLight,
MVideoFormattableDetails,
MVideoFullLight,
- MVideoIdThumbnail,
+ MVideoId,
MVideoImmutable,
MVideoThumbnail,
MVideoWithRights
break
case 'id':
- res.locals.videoId = video as MVideoIdThumbnail
+ res.locals.videoId = video as MVideoId
break
case 'only-video':
res.locals.onlyVideo = video as MVideoThumbnail
break
-
- case 'only-video-with-rights':
- res.locals.onlyVideoWithRights = video as MVideoWithRights
- break
}
return true
import { isAbleToUploadVideo } from '@server/lib/user'
import { getServerActor } from '@server/models/application/application'
import { ExpressPromiseHandler } from '@server/types/express'
-import { MUserAccountId, MVideoWithRights } from '@server/types/models'
+import { MUserAccountId, MVideoFullLight } from '@server/types/models'
import { ServerErrorCode, UserRight, VideoChangeOwnershipStatus, VideoPrivacy } from '../../../../shared'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
import { VideoChangeOwnershipAccept } from '../../../../shared/models/videos/change-ownership/video-change-ownership-accept.model'
}
const videosCustomGetValidator = (
- fetchType: 'for-api' | 'all' | 'only-video' | 'only-video-with-rights' | 'only-immutable-attributes',
+ fetchType: 'for-api' | 'all' | 'only-video' | 'only-immutable-attributes',
authenticateInQuery = false
) => {
return [
// Controllers does not need to check video rights
if (fetchType === 'only-immutable-attributes') return next()
- const video = getVideoWithAttributes(res) as MVideoWithRights
+ const video = getVideoWithAttributes(res) as MVideoFullLight
// Video private or blacklisted
if (video.requiresAuth()) {
}
}
+ 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"')
return result
}
- protected whereId (id: string | number) {
- if (validator.isInt('' + id)) {
+ protected whereId (options: { id?: string | number, url?: string }) {
+ if (options.url) {
+ this.where = 'WHERE "video"."url" = :videoUrl'
+ this.replacements.videoUrl = options.url
+ return
+ }
+
+ if (validator.isInt('' + options.id)) {
this.where = 'WHERE "video".id = :videoId'
} else {
this.where = 'WHERE uuid = :videoId'
}
- this.replacements.videoId = id
+ this.replacements.videoId = options.id
}
protected addJoin (join: string) {
protected query: string
protected replacements: any = {}
- protected runQuery (transaction?: Transaction) {
+ protected runQuery (options: { transaction?: Transaction, logging?: boolean } = {}) {
logger.debug('Running videos query.', { query: this.query, replacements: this.replacements })
- const options = {
- transaction,
+ const queryOptions = {
+ transaction: options.transaction,
+ logging: options.logging,
replacements: this.replacements,
type: QueryTypes.SELECT as QueryTypes.SELECT,
next: false
}
- return this.sequelize.query<any>(this.query, options)
+ return this.sequelize.query<any>(this.query, queryOptions)
}
}
queryWebTorrentVideos (options: BuildVideoGetQueryOptions) {
this.buildWebtorrentFilesQuery(options)
- return this.runQuery(options.transaction)
+ return this.runQuery(options)
}
queryStreamingPlaylistVideos (options: BuildVideoGetQueryOptions) {
this.buildVideoStreamingPlaylistFilesQuery(options)
- return this.runQuery(options.transaction)
+ return this.runQuery(options)
}
private buildWebtorrentFilesQuery (options: BuildVideoGetQueryOptions) {
this.includeWebtorrentFiles(true)
- if (options.forGetAPI === true) {
+ if (this.shouldIncludeRedundancies(options)) {
this.includeWebTorrentRedundancies()
}
- this.whereId(options.id)
+ this.whereId(options)
this.query = this.buildQuery()
}
this.includeStreamingPlaylistFiles(true)
- if (options.forGetAPI === true) {
+ if (this.shouldIncludeRedundancies(options)) {
this.includeStreamingPlaylistRedundancies()
}
- this.whereId(options.id)
+ this.whereId(options)
this.query = this.buildQuery()
}
private buildQuery () {
return `${this.buildSelect()} FROM "video" ${this.joins} ${this.where}`
}
+
+ private shouldIncludeRedundancies (options: BuildVideoGetQueryOptions) {
+ return options.type === 'api'
+ }
}
-import { logger } from '@server/helpers/logger'
import { AccountModel } from '@server/models/account/account'
import { ActorModel } from '@server/models/actor/actor'
import { ActorImageModel } from '@server/models/actor/actor-image'
this.reinit()
for (const row of rows) {
- this.buildVideo(row)
+ this.buildVideoAndAccount(row)
const videoModel = this.videosMemo[row.id]
}
}
- private buildVideo (row: SQLRow) {
+ private buildVideoAndAccount (row: SQLRow) {
if (this.videosMemo[row.id]) return
- // Build Channel
- const channelModel = new VideoChannelModel(this.grab(row, this.tables.getChannelAttributes(), 'VideoChannel'), this.buildOpts)
- channelModel.Actor = this.buildActor(row, 'VideoChannel')
-
- const accountModel = new AccountModel(this.grab(row, this.tables.getAccountAttributes(), 'VideoChannel.Account'), this.buildOpts)
- accountModel.Actor = this.buildActor(row, 'VideoChannel.Account')
-
- channelModel.Account = accountModel
-
const videoModel = new VideoModel(this.grab(row, this.tables.getVideoAttributes(), ''), this.buildOpts)
- videoModel.VideoChannel = channelModel
-
- this.videosMemo[row.id] = videoModel
videoModel.UserVideoHistories = []
videoModel.Thumbnails = []
videoModel.Tags = []
videoModel.Trackers = []
+ this.buildAccount(row, videoModel)
+
+ this.videosMemo[row.id] = videoModel
+
// Keep rows order
this.videos.push(videoModel)
}
+ private buildAccount (row: SQLRow, videoModel: VideoModel) {
+ const id = row['VideoChannel.Account.id']
+ if (!id) return
+
+ const channelModel = new VideoChannelModel(this.grab(row, this.tables.getChannelAttributes(), 'VideoChannel'), this.buildOpts)
+ channelModel.Actor = this.buildActor(row, 'VideoChannel')
+
+ const accountModel = new AccountModel(this.grab(row, this.tables.getAccountAttributes(), 'VideoChannel.Account'), this.buildOpts)
+ accountModel.Actor = this.buildActor(row, 'VideoChannel.Account')
+
+ channelModel.Account = accountModel
+
+ videoModel.VideoChannel = channelModel
+ }
+
private buildActor (row: SQLRow, prefix: string) {
const actorPrefix = `${prefix}.Actor`
const avatarPrefix = `${actorPrefix}.Avatar`
}
+ getChannelAttributesForUser () {
+ return [ 'id', 'accountId' ]
+ }
+
getChannelAttributes () {
let attributeKeys = [
'id',
return attributeKeys
}
+ getUserAccountAttributes () {
+ return [ 'id', 'userId' ]
+ }
+
getAccountAttributes () {
let attributeKeys = [ 'id', 'name', 'actorId' ]
*/
export type BuildVideoGetQueryOptions = {
- id: number | string
- transaction?: Transaction
+ id?: number | string
+ url?: string
+
+ type: 'api' | 'full-light' | 'account-blacklist-files' | 'all-files' | 'thumbnails' | 'thumbnails-blacklist' | 'id' | 'blacklist-rights'
+
userId?: number
- forGetAPI?: boolean
+ transaction?: Transaction
+
+ logging?: boolean
}
export class VideosModelGetQueryBuilder {
this.videoModelBuilder = new VideoModelBuilder('get', new VideoTables('get'))
}
- async queryVideos (options: BuildVideoGetQueryOptions) {
+ async queryVideo (options: BuildVideoGetQueryOptions) {
const [ videoRows, webtorrentFilesRows, streamingPlaylistFilesRows ] = await Promise.all([
this.videoQueryBuilder.queryVideos(options),
- this.webtorrentFilesQueryBuilder.queryWebTorrentVideos(options),
- this.streamingPlaylistFilesQueryBuilder.queryStreamingPlaylistVideos(options)
+
+ this.shouldQueryVideoFiles(options)
+ ? this.webtorrentFilesQueryBuilder.queryWebTorrentVideos(options)
+ : Promise.resolve(undefined),
+
+ this.shouldQueryVideoFiles(options)
+ ? this.streamingPlaylistFilesQueryBuilder.queryStreamingPlaylistVideos(options)
+ : Promise.resolve(undefined)
])
const videos = this.videoModelBuilder.buildVideosFromRows(videoRows, webtorrentFilesRows, streamingPlaylistFilesRows)
if (videos.length === 0) return null
return videos[0]
}
+
+ private shouldQueryVideoFiles (options: BuildVideoGetQueryOptions) {
+ return [ 'api', 'full-light', 'account-blacklist-files', 'all-files' ].includes(options.type)
+ }
}
export class VideosModelGetQuerySubBuilder extends AbstractVideosModelQueryBuilder {
queryVideos (options: BuildVideoGetQueryOptions) {
this.buildMainGetQuery(options)
- return this.runQuery(options.transaction)
+ return this.runQuery(options)
}
private buildMainGetQuery (options: BuildVideoGetQueryOptions) {
'"video".*': ''
}
- this.includeChannels()
- this.includeAccounts()
+ if (this.shouldIncludeThumbnails(options)) {
+ this.includeThumbnails()
+ }
- this.includeTags()
+ if (this.shouldIncludeBlacklisted(options)) {
+ this.includeBlacklisted()
+ }
- this.includeThumbnails()
+ if (this.shouldIncludeAccount(options)) {
+ this.includeChannels()
+ this.includeAccounts()
+ }
- this.includeBlacklisted()
+ if (this.shouldIncludeTags(options)) {
+ this.includeTags()
+ }
- this.includeScheduleUpdate()
+ if (this.shouldIncludeScheduleUpdate(options)) {
+ this.includeScheduleUpdate()
+ }
- this.includeLive()
+ if (this.shouldIncludeLive(options)) {
+ this.includeLive()
+ }
- if (options.userId) {
+ if (options.userId && this.shouldIncludeUserHistory(options)) {
this.includeUserHistory(options.userId)
}
- if (options.forGetAPI === true) {
+ if (this.shouldIncludeOwnerUser(options)) {
+ this.includeOwnerUser()
+ }
+
+ if (this.shouldIncludeTrackers(options)) {
this.includeTrackers()
}
- this.whereId(options.id)
+ this.whereId(options)
- this.query = this.buildQuery()
+ this.query = this.buildQuery(options)
}
- private buildQuery () {
- const order = 'ORDER BY "Tags"."name" ASC'
+ private buildQuery (options: BuildVideoGetQueryOptions) {
+ const order = this.shouldIncludeTags(options)
+ ? 'ORDER BY "Tags"."name" ASC'
+ : ''
+
const from = `SELECT * FROM "video" ${this.where} LIMIT 1`
return `${this.buildSelect()} FROM (${from}) AS "video" ${this.joins} ${order}`
}
+
+ private shouldIncludeTrackers (options: BuildVideoGetQueryOptions) {
+ return options.type === 'api'
+ }
+
+ private shouldIncludeLive (options: BuildVideoGetQueryOptions) {
+ return [ 'api', 'full-light' ].includes(options.type)
+ }
+
+ private shouldIncludeScheduleUpdate (options: BuildVideoGetQueryOptions) {
+ return [ 'api', 'full-light' ].includes(options.type)
+ }
+
+ private shouldIncludeTags (options: BuildVideoGetQueryOptions) {
+ return [ 'api', 'full-light' ].includes(options.type)
+ }
+
+ private shouldIncludeUserHistory (options: BuildVideoGetQueryOptions) {
+ return [ 'api', 'full-light' ].includes(options.type)
+ }
+
+ private shouldIncludeAccount (options: BuildVideoGetQueryOptions) {
+ return [ 'api', 'full-light', 'account-blacklist-files' ].includes(options.type)
+ }
+
+ private shouldIncludeBlacklisted (options: BuildVideoGetQueryOptions) {
+ return [ 'api', 'full-light', 'account-blacklist-files', 'thumbnails-blacklist', 'blacklist-rights' ].includes(options.type)
+ }
+
+ private shouldIncludeOwnerUser (options: BuildVideoGetQueryOptions) {
+ return options.type === 'blacklist-rights'
+ }
+
+ private shouldIncludeThumbnails (options: BuildVideoGetQueryOptions) {
+ return [ 'api', 'full-light', 'account-blacklist-files', 'thumbnails', 'thumbnails-blacklist' ].includes(options.type)
+ }
}
this.buildInnerQuery(options)
this.buildListQueryFromIdsQuery(options)
- return this.runQuery(undefined).then(rows => this.videoModelBuilder.buildVideosFromRows(rows))
+ return this.runQuery()
+ .then(rows => this.videoModelBuilder.buildVideosFromRows(rows))
}
private buildInnerQuery (options: BuildVideosListQueryOptions) {
MVideoFormattableDetails,
MVideoForUser,
MVideoFullLight,
- MVideoIdThumbnail,
+ MVideoId,
MVideoImmutable,
MVideoThumbnail,
MVideoThumbnailBlacklist,
MVideoWithAllFiles,
- MVideoWithFile,
- MVideoWithRights
+ MVideoWithFile
} from '../../types/models'
import { MThumbnail } from '../../types/models/video/thumbnail'
import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../types/models/video/video-file'
return VideoModel.count(options)
}
- static load (id: number | string, t?: Transaction): Promise<MVideoThumbnail> {
- const where = buildWhereIdOrUUID(id)
- const options = {
- where,
- transaction: t
- }
+ static load (id: number | string, transaction?: Transaction): Promise<MVideoThumbnail> {
+ const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize)
- return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(options)
+ return queryBuilder.queryVideo({ id, transaction, type: 'thumbnails' })
}
- static loadWithBlacklist (id: number | string, t?: Transaction): Promise<MVideoThumbnailBlacklist> {
- const where = buildWhereIdOrUUID(id)
- const options = {
- where,
- transaction: t
- }
+ static loadWithBlacklist (id: number | string, transaction?: Transaction): Promise<MVideoThumbnailBlacklist> {
+ const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize)
- return VideoModel.scope([
- ScopeNames.WITH_THUMBNAILS,
- ScopeNames.WITH_BLACKLISTED
- ]).findOne(options)
+ return queryBuilder.queryVideo({ id, transaction, type: 'thumbnails-blacklist' })
}
static loadImmutableAttributes (id: number | string, t?: Transaction): Promise<MVideoImmutable> {
})
}
- static loadWithRights (id: number | string, t?: Transaction): Promise<MVideoWithRights> {
- const where = buildWhereIdOrUUID(id)
- const options = {
- where,
- transaction: t
- }
-
- return VideoModel.scope([
- ScopeNames.WITH_BLACKLISTED,
- ScopeNames.WITH_USER_ID
- ]).findOne(options)
- }
-
- static loadOnlyId (id: number | string, t?: Transaction): Promise<MVideoIdThumbnail> {
- const where = buildWhereIdOrUUID(id)
-
- const options = {
- attributes: [ 'id' ],
- where,
- transaction: t
- }
-
- return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(options)
- }
-
- static loadWithFiles (id: number | string, t?: Transaction, logging?: boolean): Promise<MVideoWithAllFiles> {
- const where = buildWhereIdOrUUID(id)
-
- const query = {
- where,
- transaction: t,
- logging
- }
-
- return VideoModel.scope([
- ScopeNames.WITH_WEBTORRENT_FILES,
- ScopeNames.WITH_STREAMING_PLAYLISTS,
- ScopeNames.WITH_THUMBNAILS
- ]).findOne(query)
- }
-
- static loadByUUID (uuid: string): Promise<MVideoThumbnail> {
- const options = {
- where: {
- uuid
- }
- }
-
- return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(options)
- }
-
- static loadByUrl (url: string, transaction?: Transaction): Promise<MVideoThumbnail> {
- const query: FindOptions = {
- where: {
- url
- },
- transaction
- }
-
- return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(query)
- }
-
static loadByUrlImmutableAttributes (url: string, transaction?: Transaction): Promise<MVideoImmutable> {
const fun = () => {
const query: FindOptions = {
})
}
- static loadByUrlAndPopulateAccount (url: string, transaction?: Transaction): Promise<MVideoAccountLightBlacklistAllFiles> {
- const query: FindOptions = {
- where: {
- url
- },
- transaction
- }
+ static loadOnlyId (id: number | string, transaction?: Transaction): Promise<MVideoId> {
+ const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize)
- return VideoModel.scope([
- ScopeNames.WITH_ACCOUNT_DETAILS,
- ScopeNames.WITH_WEBTORRENT_FILES,
- ScopeNames.WITH_STREAMING_PLAYLISTS,
- ScopeNames.WITH_THUMBNAILS,
- ScopeNames.WITH_BLACKLISTED
- ]).findOne(query)
+ return queryBuilder.queryVideo({ id, transaction, type: 'id' })
}
- static loadAndPopulateAccountAndServerAndTags (id: number | string, t?: Transaction, userId?: number): Promise<MVideoFullLight> {
- const where = buildWhereIdOrUUID(id)
+ static loadWithFiles (id: number | string, transaction?: Transaction, logging?: boolean): Promise<MVideoWithAllFiles> {
+ const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize)
- const options = {
- order: [ [ 'Tags', 'name', 'ASC' ] ] as any,
- where,
- transaction: t
- }
+ return queryBuilder.queryVideo({ id, transaction, type: 'all-files', logging })
+ }
- const scopes: (string | ScopeOptions)[] = [
- ScopeNames.WITH_TAGS,
- ScopeNames.WITH_BLACKLISTED,
- ScopeNames.WITH_ACCOUNT_DETAILS,
- ScopeNames.WITH_SCHEDULED_UPDATE,
- ScopeNames.WITH_WEBTORRENT_FILES,
- ScopeNames.WITH_STREAMING_PLAYLISTS,
- ScopeNames.WITH_THUMBNAILS,
- ScopeNames.WITH_LIVE
- ]
+ static loadByUrl (url: string, transaction?: Transaction): Promise<MVideoThumbnail> {
+ const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize)
- if (userId) {
- scopes.push({ method: [ ScopeNames.WITH_USER_HISTORY, userId ] })
- }
+ return queryBuilder.queryVideo({ url, transaction, type: 'thumbnails' })
+ }
+
+ static loadByUrlAndPopulateAccount (url: string, transaction?: Transaction): Promise<MVideoAccountLightBlacklistAllFiles> {
+ const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize)
+
+ return queryBuilder.queryVideo({ url, transaction, type: 'account-blacklist-files' })
+ }
+
+ static loadAndPopulateAccountAndServerAndTags (id: number | string, t?: Transaction, userId?: number): Promise<MVideoFullLight> {
+ const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize)
- return VideoModel
- .scope(scopes)
- .findOne(options)
+ return queryBuilder.queryVideo({ id, transaction: t, type: 'full-light', userId })
}
static loadForGetAPI (parameters: {
const { id, transaction, userId } = parameters
const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize)
- return queryBuilder.queryVideos({ id, transaction, forGetAPI: true, userId })
+ return queryBuilder.queryVideo({ id, transaction, type: 'api', userId })
}
static async getStats () {
MVideoChangeOwnershipFull,
MVideoFile,
MVideoFormattableDetails,
+ MVideoId,
MVideoImmutable,
MVideoLive,
MVideoPlaylistFull,
videoAll?: MVideoFullLight
onlyImmutableVideo?: MVideoImmutable
onlyVideo?: MVideoThumbnail
- onlyVideoWithRights?: MVideoWithRights
- videoId?: MVideoIdThumbnail
+ videoId?: MVideoId
videoLive?: MVideoLive