From a056ca4813c82f490dcd31ac97a64d6bf76d3dcc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 28 Oct 2020 15:24:40 +0100 Subject: Add max lives limit --- server/models/video/video.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'server/models/video/video.ts') diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 78fec5585..d094f19b0 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -1142,6 +1142,37 @@ export class VideoModel extends Model { return VideoModel.getAvailableForApi(queryOptions) } + static countLocalLives () { + const options = { + where: { + remote: false, + isLive: true + } + } + + return VideoModel.count(options) + } + + static countLivesOfAccount (accountId: number) { + const options = { + where: { + remote: false, + isLive: true + }, + include: [ + { + required: true, + model: VideoChannelModel.unscoped(), + where: { + accountId + } + } + ] + } + + return VideoModel.count(options) + } + static load (id: number | string, t?: Transaction): Bluebird { const where = buildWhereIdOrUUID(id) const options = { -- cgit v1.2.3