import { VideoImport, VideoImportState } from '../../../shared'
import { isVideoMagnetUriValid } from '../../helpers/custom-validators/videos'
import { UserModel } from '../account/user'
+import * as Bluebird from 'bluebird'
+import { MVideoImportDefault, MVideoImportFormattable } from '@server/typings/models/video/video-import'
-@DefaultScope({
+@DefaultScope(() => ({
include: [
{
- model: () => UserModel.unscoped(),
+ model: UserModel.unscoped(),
required: true
},
{
- model: () => VideoModel.scope([ VideoModelScopeNames.WITH_ACCOUNT_DETAILS, VideoModelScopeNames.WITH_TAGS]),
+ model: VideoModel.scope([
+ VideoModelScopeNames.WITH_ACCOUNT_DETAILS,
+ VideoModelScopeNames.WITH_TAGS,
+ VideoModelScopeNames.WITH_THUMBNAILS
+ ]),
required: false
}
]
-})
+}))
@Table({
tableName: 'videoImport',
return undefined
}
- static loadAndPopulateVideo (id: number) {
+ static loadAndPopulateVideo (id: number): Bluebird<MVideoImportDefault> {
return VideoImportModel.findByPk(id)
}
distinct: true,
include: [
{
+ attributes: [ 'id' ],
model: UserModel.unscoped(), // FIXME: Without this, sequelize try to COUNT(DISTINCT(*)) which is an invalid SQL query
required: true
}
}
}
- return VideoImportModel.findAndCountAll(query)
+ return VideoImportModel.findAndCountAll<MVideoImportDefault>(query)
.then(({ rows, count }) => {
return {
data: rows,
return this.targetUrl || this.magnetUri || this.torrentName
}
- toFormattedJSON (): VideoImport {
+ toFormattedJSON (this: MVideoImportFormattable): VideoImport {
const videoFormatOptions = {
completeDescription: true,
additionalAttributes: { state: true, waitTranscoding: true, scheduledUpdate: true }