From 97969c4edf51b37eee691adba43368bb0fbb729b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 3 Nov 2020 15:33:30 +0100 Subject: Add check constraints live tests --- server/models/account/user.ts | 3 +-- server/models/video/video-file.ts | 8 ++++++++ server/models/video/video.ts | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'server/models') diff --git a/server/models/account/user.ts b/server/models/account/user.ts index f64568c54..2aa6469fb 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -26,7 +26,6 @@ import { MUser, MUserDefault, MUserFormattable, - MUserId, MUserNotifSettingChannelDefault, MUserWithNotificationSetting, MVideoFullLight @@ -68,10 +67,10 @@ import { getSort, throwIfNotValid } from '../utils' import { VideoModel } from '../video/video' import { VideoChannelModel } from '../video/video-channel' import { VideoImportModel } from '../video/video-import' +import { VideoLiveModel } from '../video/video-live' import { VideoPlaylistModel } from '../video/video-playlist' import { AccountModel } from './account' import { UserNotificationSettingModel } from './user-notification-setting' -import { VideoLiveModel } from '../video/video-live' enum ScopeNames { FOR_ME_API = 'FOR_ME_API', diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts index 6a321917c..8c8fc0b51 100644 --- a/server/models/video/video-file.ts +++ b/server/models/video/video-file.ts @@ -311,6 +311,14 @@ export class VideoFileModel extends Model { return element.save({ transaction }) } + static removeHLSFilesOfVideoId (videoStreamingPlaylistId: number) { + const options = { + where: { videoStreamingPlaylistId } + } + + return VideoFileModel.destroy(options) + } + getVideoOrStreamingPlaylist (this: MVideoFileVideo | MVideoFileStreamingPlaylistVideo): MVideo | MStreamingPlaylistVideo { if (this.videoId) return (this as MVideoFileVideo).Video diff --git a/server/models/video/video.ts b/server/models/video/video.ts index aba8c8cf4..7e008f7ea 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -249,7 +249,7 @@ export type AvailableForListIDsOptions = { [ScopeNames.WITH_LIVE]: { include: [ { - model: VideoLiveModel, + model: VideoLiveModel.unscoped(), required: false } ] -- cgit v1.2.3