import { VideoChannelModel } from './video-channel'
import { AccountModel } from '../account/account'
import { TagModel } from './tag'
+import { isVideoMagnetUriValid } from '../../helpers/custom-validators/videos'
@DefaultScope({
include: [
]
},
{
- model: () => TagModel,
- required: false
+ model: () => TagModel
}
]
}
@UpdatedAt
updatedAt: Date
- @AllowNull(false)
+ @AllowNull(true)
+ @Default(null)
@Is('VideoImportTargetUrl', value => throwIfNotValid(value, isVideoImportTargetUrlValid, 'targetUrl'))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_IMPORTS.URL.max))
targetUrl: string
+ @AllowNull(true)
+ @Default(null)
+ @Is('VideoImportMagnetUri', value => throwIfNotValid(value, isVideoMagnetUriValid, 'magnetUri'))
+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_IMPORTS.URL.max)) // Use the same constraints than URLs
+ magnetUri: string
+
+ @AllowNull(true)
+ @Default(null)
+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_IMPORTS.TORRENT_NAME.max))
+ torrentName: string
+
@AllowNull(false)
@Default(null)
@Is('VideoImportState', value => throwIfNotValid(value, isVideoImportStateValid, 'state'))
static listUserVideoImportsForApi (accountId: number, start: number, count: number, sort: string) {
const query = {
+ distinct: true,
offset: start,
limit: count,
order: getSort(sort),
return {
id: this.id,
+
targetUrl: this.targetUrl,
+ magnetUri: this.magnetUri,
+ torrentName: this.torrentName,
+
state: {
id: this.state,
label: VideoImportModel.getStateLabel(this.state)