diff options
Diffstat (limited to 'server/models/video/video-caption.ts')
-rw-r--r-- | server/models/video/video-caption.ts | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/server/models/video/video-caption.ts b/server/models/video/video-caption.ts index b68a6e99f..e8e883dd0 100644 --- a/server/models/video/video-caption.ts +++ b/server/models/video/video-caption.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | import { remove } from 'fs-extra' | ||
2 | import { join } from 'path' | ||
1 | import { OrderItem, Transaction } from 'sequelize' | 3 | import { OrderItem, Transaction } from 'sequelize' |
2 | import { | 4 | import { |
3 | AllowNull, | 5 | AllowNull, |
@@ -13,18 +15,15 @@ import { | |||
13 | Table, | 15 | Table, |
14 | UpdatedAt | 16 | UpdatedAt |
15 | } from 'sequelize-typescript' | 17 | } from 'sequelize-typescript' |
16 | import { buildWhereIdOrUUID, throwIfNotValid } from '../utils' | 18 | import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub' |
17 | import { VideoModel } from './video' | 19 | import { MVideoAccountLight, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models' |
18 | import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' | ||
19 | import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' | 20 | import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' |
20 | import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, VIDEO_LANGUAGES, WEBSERVER } from '../../initializers/constants' | 21 | import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' |
21 | import { join } from 'path' | ||
22 | import { logger } from '../../helpers/logger' | 22 | import { logger } from '../../helpers/logger' |
23 | import { remove } from 'fs-extra' | ||
24 | import { CONFIG } from '../../initializers/config' | 23 | import { CONFIG } from '../../initializers/config' |
25 | import * as Bluebird from 'bluebird' | 24 | import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, VIDEO_LANGUAGES, WEBSERVER } from '../../initializers/constants' |
26 | import { MVideoAccountLight, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models' | 25 | import { buildWhereIdOrUUID, throwIfNotValid } from '../utils' |
27 | import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub' | 26 | import { VideoModel } from './video' |
28 | 27 | ||
29 | export enum ScopeNames { | 28 | export enum ScopeNames { |
30 | WITH_VIDEO_UUID_AND_REMOTE = 'WITH_VIDEO_UUID_AND_REMOTE' | 29 | WITH_VIDEO_UUID_AND_REMOTE = 'WITH_VIDEO_UUID_AND_REMOTE' |
@@ -54,7 +53,7 @@ export enum ScopeNames { | |||
54 | } | 53 | } |
55 | ] | 54 | ] |
56 | }) | 55 | }) |
57 | export class VideoCaptionModel extends Model<VideoCaptionModel> { | 56 | export class VideoCaptionModel extends Model { |
58 | @CreatedAt | 57 | @CreatedAt |
59 | createdAt: Date | 58 | createdAt: Date |
60 | 59 | ||
@@ -101,7 +100,7 @@ export class VideoCaptionModel extends Model<VideoCaptionModel> { | |||
101 | return undefined | 100 | return undefined |
102 | } | 101 | } |
103 | 102 | ||
104 | static loadByVideoIdAndLanguage (videoId: string | number, language: string): Bluebird<MVideoCaptionVideo> { | 103 | static loadByVideoIdAndLanguage (videoId: string | number, language: string): Promise<MVideoCaptionVideo> { |
105 | const videoInclude = { | 104 | const videoInclude = { |
106 | model: VideoModel.unscoped(), | 105 | model: VideoModel.unscoped(), |
107 | attributes: [ 'id', 'remote', 'uuid' ], | 106 | attributes: [ 'id', 'remote', 'uuid' ], |
@@ -131,7 +130,7 @@ export class VideoCaptionModel extends Model<VideoCaptionModel> { | |||
131 | .then(([ caption ]) => caption) | 130 | .then(([ caption ]) => caption) |
132 | } | 131 | } |
133 | 132 | ||
134 | static listVideoCaptions (videoId: number): Bluebird<MVideoCaptionVideo[]> { | 133 | static listVideoCaptions (videoId: number): Promise<MVideoCaptionVideo[]> { |
135 | const query = { | 134 | const query = { |
136 | order: [ [ 'language', 'ASC' ] ] as OrderItem[], | 135 | order: [ [ 'language', 'ASC' ] ] as OrderItem[], |
137 | where: { | 136 | where: { |