Table,
UpdatedAt
} from 'sequelize-typescript'
-import { v4 as uuidv4 } from 'uuid'
import { MVideo, MVideoCaption, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models'
-import { AttributesOnly } from '@shared/core-utils'
+import { buildUUID } from '@shared/extra-utils'
+import { AttributesOnly } from '@shared/typescript-utils'
import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model'
import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions'
import { logger } from '../../helpers/logger'
Video: VideoModel
@BeforeDestroy
- static async removeFiles (instance: VideoCaptionModel) {
+ static async removeFiles (instance: VideoCaptionModel, options) {
if (!instance.Video) {
- instance.Video = await instance.$get('Video')
+ instance.Video = await instance.$get('Video', { transaction: options.transaction })
}
if (instance.isOwned()) {
const videoInclude = {
model: VideoModel.unscoped(),
attributes: [ 'id', 'remote', 'uuid' ],
- where: buildWhereIdOrUUID(videoId),
- transaction
+ where: buildWhereIdOrUUID(videoId)
}
const query = {
},
include: [
videoInclude
- ]
+ ],
+ transaction
}
return VideoCaptionModel.findOne(query)
}
static generateCaptionName (language: string) {
- return `${uuidv4()}-${language}.vtt`
+ return `${buildUUID()}-${language}.vtt`
}
isOwned () {
id: this.language,
label: VideoCaptionModel.getLanguageLabel(this.language)
},
- captionPath: this.getCaptionStaticPath()
+ captionPath: this.getCaptionStaticPath(),
+ updatedAt: this.updatedAt.toISOString()
}
}