aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts17
1 files changed, 9 insertions, 8 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 18afba1ba..d4a258187 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -31,6 +31,7 @@ import { LiveManager } from '@server/lib/live-manager'
31import { getHLSDirectory, getVideoFilePath } from '@server/lib/video-paths' 31import { getHLSDirectory, getVideoFilePath } from '@server/lib/video-paths'
32import { getServerActor } from '@server/models/application/application' 32import { getServerActor } from '@server/models/application/application'
33import { ModelCache } from '@server/models/model-cache' 33import { ModelCache } from '@server/models/model-cache'
34import { AttributesOnly } from '@shared/core-utils'
34import { VideoFile } from '@shared/models/videos/video-file.model' 35import { VideoFile } from '@shared/models/videos/video-file.model'
35import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared' 36import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared'
36import { VideoObject } from '../../../shared/models/activitypub/objects' 37import { VideoObject } from '../../../shared/models/activitypub/objects'
@@ -100,14 +101,14 @@ import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../types/models
100import { VideoAbuseModel } from '../abuse/video-abuse' 101import { VideoAbuseModel } from '../abuse/video-abuse'
101import { AccountModel } from '../account/account' 102import { AccountModel } from '../account/account'
102import { AccountVideoRateModel } from '../account/account-video-rate' 103import { AccountVideoRateModel } from '../account/account-video-rate'
103import { ActorImageModel } from '../account/actor-image' 104import { ActorModel } from '../actor/actor'
104import { UserModel } from '../account/user' 105import { ActorImageModel } from '../actor/actor-image'
105import { UserVideoHistoryModel } from '../account/user-video-history'
106import { ActorModel } from '../activitypub/actor'
107import { VideoRedundancyModel } from '../redundancy/video-redundancy' 106import { VideoRedundancyModel } from '../redundancy/video-redundancy'
108import { ServerModel } from '../server/server' 107import { ServerModel } from '../server/server'
109import { TrackerModel } from '../server/tracker' 108import { TrackerModel } from '../server/tracker'
110import { VideoTrackerModel } from '../server/video-tracker' 109import { VideoTrackerModel } from '../server/video-tracker'
110import { UserModel } from '../user/user'
111import { UserVideoHistoryModel } from '../user/user-video-history'
111import { buildTrigramSearchIndex, buildWhereIdOrUUID, getVideoSort, isOutdated, throwIfNotValid } from '../utils' 112import { buildTrigramSearchIndex, buildWhereIdOrUUID, getVideoSort, isOutdated, throwIfNotValid } from '../utils'
112import { ScheduleVideoUpdateModel } from './schedule-video-update' 113import { ScheduleVideoUpdateModel } from './schedule-video-update'
113import { TagModel } from './tag' 114import { TagModel } from './tag'
@@ -489,7 +490,7 @@ export type AvailableForListIDsOptions = {
489 } 490 }
490 ] 491 ]
491}) 492})
492export class VideoModel extends Model { 493export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
493 494
494 @AllowNull(false) 495 @AllowNull(false)
495 @Default(DataType.UUIDV4) 496 @Default(DataType.UUIDV4)
@@ -1618,7 +1619,7 @@ export class VideoModel extends Model {
1618 includeLocalVideos: true 1619 includeLocalVideos: true
1619 } 1620 }
1620 1621
1621 const { query, replacements } = buildListQuery(VideoModel, queryOptions) 1622 const { query, replacements } = buildListQuery(VideoModel.sequelize, queryOptions)
1622 1623
1623 return this.sequelize.query<any>(query, { replacements, type: QueryTypes.SELECT }) 1624 return this.sequelize.query<any>(query, { replacements, type: QueryTypes.SELECT })
1624 .then(rows => rows.map(r => r[field])) 1625 .then(rows => rows.map(r => r[field]))
@@ -1646,7 +1647,7 @@ export class VideoModel extends Model {
1646 if (countVideos !== true) return Promise.resolve(undefined) 1647 if (countVideos !== true) return Promise.resolve(undefined)
1647 1648
1648 const countOptions = Object.assign({}, options, { isCount: true }) 1649 const countOptions = Object.assign({}, options, { isCount: true })
1649 const { query: queryCount, replacements: replacementsCount } = buildListQuery(VideoModel, countOptions) 1650 const { query: queryCount, replacements: replacementsCount } = buildListQuery(VideoModel.sequelize, countOptions)
1650 1651
1651 return VideoModel.sequelize.query<any>(queryCount, { replacements: replacementsCount, type: QueryTypes.SELECT }) 1652 return VideoModel.sequelize.query<any>(queryCount, { replacements: replacementsCount, type: QueryTypes.SELECT })
1652 .then(rows => rows.length !== 0 ? rows[0].total : 0) 1653 .then(rows => rows.length !== 0 ? rows[0].total : 0)
@@ -1655,7 +1656,7 @@ export class VideoModel extends Model {
1655 function getModels () { 1656 function getModels () {
1656 if (options.count === 0) return Promise.resolve([]) 1657 if (options.count === 0) return Promise.resolve([])
1657 1658
1658 const { query, replacements, order } = buildListQuery(VideoModel, options) 1659 const { query, replacements, order } = buildListQuery(VideoModel.sequelize, options)
1659 const queryModels = wrapForAPIResults(query, replacements, options, order) 1660 const queryModels = wrapForAPIResults(query, replacements, options, order)
1660 1661
1661 return VideoModel.sequelize.query<any>(queryModels, { replacements, type: QueryTypes.SELECT, nest: true }) 1662 return VideoModel.sequelize.query<any>(queryModels, { replacements, type: QueryTypes.SELECT, nest: true })