From 31c82cd914e13dbf53280d0aad0740d70c414441 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 27 Oct 2020 16:06:24 +0100 Subject: Fix replay saving --- server/models/account/user.ts | 4 ++-- server/models/video/video.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'server/models') diff --git a/server/models/account/user.ts b/server/models/account/user.ts index e850d1e6d..f64568c54 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -710,7 +710,7 @@ export class UserModel extends Model { required: true, include: [ { - attributes: [ 'id', 'videoId' ], + attributes: [], model: VideoLiveModel.unscoped(), required: true, where: { @@ -726,7 +726,7 @@ export class UserModel extends Model { ] } - return UserModel.findOne(query) + return UserModel.unscoped().findOne(query) } static generateUserQuotaBaseSQL (options: { diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 8493ab802..78fec5585 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -128,6 +128,7 @@ import { VideoStreamingPlaylistModel } from './video-streaming-playlist' import { VideoTagModel } from './video-tag' import { VideoViewModel } from './video-view' import { LiveManager } from '@server/lib/live-manager' +import { VideoLiveModel } from './video-live' export enum ScopeNames { AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS', @@ -725,6 +726,15 @@ export class VideoModel extends Model { }) VideoBlacklist: VideoBlacklistModel + @HasOne(() => VideoLiveModel, { + foreignKey: { + name: 'videoId', + allowNull: false + }, + onDelete: 'cascade' + }) + VideoLive: VideoLiveModel + @HasOne(() => VideoImportModel, { foreignKey: { name: 'videoId', -- cgit v1.2.3