From 0283eaac2a8e73006c66df3cf5bb9012e37450e5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Aug 2019 13:52:49 +0200 Subject: Cleanup model types --- server/models/account/user.ts | 4 ++-- server/models/video/video-channel.ts | 11 +++++------ server/models/video/video.ts | 14 +++++++------- 3 files changed, 14 insertions(+), 15 deletions(-) (limited to 'server/models') diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 24b1626e7..cb54d79af 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -55,7 +55,7 @@ import { UserAdminFlag } from '../../../shared/models/users/user-flag.model' import { isThemeNameValid } from '../../helpers/custom-validators/plugins' import { getThemeOrDefault } from '../../lib/plugins/theme-utils' import * as Bluebird from 'bluebird' -import { MUserChannel, MUserDefault, MUserId, MUserWithNotificationSetting } from '@server/typings/models' +import { MUserNotifSettingChannelDefault, MUserDefault, MUserId, MUserWithNotificationSetting } from '@server/typings/models' enum ScopeNames { WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL' @@ -384,7 +384,7 @@ export class UserModel extends Model { return UserModel.findOne(query) } - static loadByUsernameAndPopulateChannels (username: string): Bluebird { + static loadByUsernameAndPopulateChannels (username: string): Bluebird { const query = { where: { username: { [ Op.iLike ]: username } diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 79b9e7d2b..b6a60827f 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -37,7 +37,6 @@ import * as Bluebird from 'bluebird' import { MChannelAccountDefault, MChannelActor, - MChannelActorAccountDefault, MChannelActorAccountDefaultVideos } from '../../typings/models/video' @@ -376,13 +375,13 @@ export class VideoChannelModel extends Model { }) } - static loadByIdAndPopulateAccount (id: number): Bluebird { + static loadByIdAndPopulateAccount (id: number): Bluebird { return VideoChannelModel.unscoped() .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) .findByPk(id) } - static loadByIdAndAccount (id: number, accountId: number): Bluebird { + static loadByIdAndAccount (id: number, accountId: number): Bluebird { const query = { where: { id, @@ -395,7 +394,7 @@ export class VideoChannelModel extends Model { .findOne(query) } - static loadAndPopulateAccount (id: number): Bluebird { + static loadAndPopulateAccount (id: number): Bluebird { return VideoChannelModel.unscoped() .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) .findByPk(id) @@ -427,7 +426,7 @@ export class VideoChannelModel extends Model { return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host) } - static loadLocalByNameAndPopulateAccount (name: string): Bluebird { + static loadLocalByNameAndPopulateAccount (name: string): Bluebird { const query = { include: [ { @@ -446,7 +445,7 @@ export class VideoChannelModel extends Model { .findOne(query) } - static loadByNameAndHostAndPopulateAccount (name: string, host: string): Bluebird { + static loadByNameAndHostAndPopulateAccount (name: string, host: string): Bluebird { const query = { include: [ { diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 7b1f0bc31..e62bde344 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -121,18 +121,18 @@ import { createTorrentPromise } from '../../helpers/webtorrent' import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' import { MChannel, - MChannelActorAccountDefault, + MChannelAccountDefault, MChannelId, MUserAccountId, MUserId, - MVideoAccountAllFiles, MVideoAccountLight, + MVideoAccountLightBlacklistAllFiles, MVideoDetails, + MVideoForUser, MVideoFullLight, MVideoIdThumbnail, MVideoThumbnail, MVideoWithAllFiles, - MVideoWithBlacklistThumbnailScheduled, MVideoWithRights } from '../../typings/models' import { MVideoFile, MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file' @@ -1015,7 +1015,7 @@ export class VideoModel extends Model { AccountModel ], transaction: options.transaction - }) as MChannelActorAccountDefault + }) as MChannelAccountDefault } return sendDeleteVideo(instance, options.transaction) @@ -1209,10 +1209,10 @@ export class VideoModel extends Model { return Promise.all([ VideoModel.count(countQuery), - VideoModel.scope(findScopes).findAll(findQuery) + VideoModel.scope(findScopes).findAll(findQuery) ]).then(([ count, rows ]) => { return { - data: rows as MVideoWithBlacklistThumbnailScheduled[], + data: rows, total: count } }) @@ -1468,7 +1468,7 @@ export class VideoModel extends Model { return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(query) } - static loadByUrlAndPopulateAccount (url: string, transaction?: Transaction): Bluebird { + static loadByUrlAndPopulateAccount (url: string, transaction?: Transaction): Bluebird { const query: FindOptions = { where: { url -- cgit v1.2.3