MVideoPlaylistElementFormattable,
MVideoPlaylistElementVideoUrlPlaylistPrivacy,
MVideoPlaylistVideoThumbnail
-} from '@server/typings/models/video/video-playlist-element'
-import { MUserAccountId } from '@server/typings/models'
+} from '@server/types/models/video/video-playlist-element'
+import { MUserAccountId } from '@server/types/models'
@Table({
tableName: 'videoPlaylistElement',
{
fields: [ 'videoId' ]
},
- {
- fields: [ 'videoPlaylistId', 'videoId' ],
- unique: true
- },
{
fields: [ 'url' ],
unique: true
@UpdatedAt
updatedAt: Date
- @AllowNull(false)
- @Is('VideoPlaylistUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url'))
+ @AllowNull(true)
+ @Is('VideoPlaylistUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.URL.max))
url: string
return VideoPlaylistElementModel.findByPk(playlistElementId)
}
- static loadByPlaylistAndVideoForAP (
+ static loadByPlaylistAndElementIdForAP (
playlistId: number | string,
- videoId: number | string
+ playlistElementId: number
): Bluebird<MVideoPlaylistElementVideoUrlPlaylistPrivacy> {
const playlistWhere = validator.isUUID('' + playlistId) ? { uuid: playlistId } : { id: playlistId }
- const videoWhere = validator.isUUID('' + videoId) ? { uuid: videoId } : { id: videoId }
const query = {
include: [
},
{
attributes: [ 'url' ],
- model: VideoModel.unscoped(),
- where: videoWhere
+ model: VideoModel.unscoped()
}
- ]
+ ],
+ where: {
+ id: playlistElementId
+ }
}
return VideoPlaylistElementModel.findOne(query)