diff options
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r-- | server/models/video/video.ts | 17 |
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' | |||
31 | import { getHLSDirectory, getVideoFilePath } from '@server/lib/video-paths' | 31 | import { getHLSDirectory, getVideoFilePath } from '@server/lib/video-paths' |
32 | import { getServerActor } from '@server/models/application/application' | 32 | import { getServerActor } from '@server/models/application/application' |
33 | import { ModelCache } from '@server/models/model-cache' | 33 | import { ModelCache } from '@server/models/model-cache' |
34 | import { AttributesOnly } from '@shared/core-utils' | ||
34 | import { VideoFile } from '@shared/models/videos/video-file.model' | 35 | import { VideoFile } from '@shared/models/videos/video-file.model' |
35 | import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared' | 36 | import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared' |
36 | import { VideoObject } from '../../../shared/models/activitypub/objects' | 37 | import { VideoObject } from '../../../shared/models/activitypub/objects' |
@@ -100,14 +101,14 @@ import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../types/models | |||
100 | import { VideoAbuseModel } from '../abuse/video-abuse' | 101 | import { VideoAbuseModel } from '../abuse/video-abuse' |
101 | import { AccountModel } from '../account/account' | 102 | import { AccountModel } from '../account/account' |
102 | import { AccountVideoRateModel } from '../account/account-video-rate' | 103 | import { AccountVideoRateModel } from '../account/account-video-rate' |
103 | import { ActorImageModel } from '../account/actor-image' | 104 | import { ActorModel } from '../actor/actor' |
104 | import { UserModel } from '../account/user' | 105 | import { ActorImageModel } from '../actor/actor-image' |
105 | import { UserVideoHistoryModel } from '../account/user-video-history' | ||
106 | import { ActorModel } from '../activitypub/actor' | ||
107 | import { VideoRedundancyModel } from '../redundancy/video-redundancy' | 106 | import { VideoRedundancyModel } from '../redundancy/video-redundancy' |
108 | import { ServerModel } from '../server/server' | 107 | import { ServerModel } from '../server/server' |
109 | import { TrackerModel } from '../server/tracker' | 108 | import { TrackerModel } from '../server/tracker' |
110 | import { VideoTrackerModel } from '../server/video-tracker' | 109 | import { VideoTrackerModel } from '../server/video-tracker' |
110 | import { UserModel } from '../user/user' | ||
111 | import { UserVideoHistoryModel } from '../user/user-video-history' | ||
111 | import { buildTrigramSearchIndex, buildWhereIdOrUUID, getVideoSort, isOutdated, throwIfNotValid } from '../utils' | 112 | import { buildTrigramSearchIndex, buildWhereIdOrUUID, getVideoSort, isOutdated, throwIfNotValid } from '../utils' |
112 | import { ScheduleVideoUpdateModel } from './schedule-video-update' | 113 | import { ScheduleVideoUpdateModel } from './schedule-video-update' |
113 | import { TagModel } from './tag' | 114 | import { TagModel } from './tag' |
@@ -489,7 +490,7 @@ export type AvailableForListIDsOptions = { | |||
489 | } | 490 | } |
490 | ] | 491 | ] |
491 | }) | 492 | }) |
492 | export class VideoModel extends Model { | 493 | export 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 }) |