aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-caption.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-caption.ts')
-rw-r--r--server/models/video/video-caption.ts23
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 @@
1import { remove } from 'fs-extra'
2import { join } from 'path'
1import { OrderItem, Transaction } from 'sequelize' 3import { OrderItem, Transaction } from 'sequelize'
2import { 4import {
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'
16import { buildWhereIdOrUUID, throwIfNotValid } from '../utils' 18import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub'
17import { VideoModel } from './video' 19import { MVideoAccountLight, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models'
18import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions'
19import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' 20import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model'
20import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, VIDEO_LANGUAGES, WEBSERVER } from '../../initializers/constants' 21import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions'
21import { join } from 'path'
22import { logger } from '../../helpers/logger' 22import { logger } from '../../helpers/logger'
23import { remove } from 'fs-extra'
24import { CONFIG } from '../../initializers/config' 23import { CONFIG } from '../../initializers/config'
25import * as Bluebird from 'bluebird' 24import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, VIDEO_LANGUAGES, WEBSERVER } from '../../initializers/constants'
26import { MVideoAccountLight, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models' 25import { buildWhereIdOrUUID, throwIfNotValid } from '../utils'
27import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub' 26import { VideoModel } from './video'
28 27
29export enum ScopeNames { 28export 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})
57export class VideoCaptionModel extends Model<VideoCaptionModel> { 56export 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: {