aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-10-28 15:24:40 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commita056ca4813c82f490dcd31ac97a64d6bf76d3dcc (patch)
tree11a0638cb92eee94f404e294f54632212836a4a6 /server/models
parentd846d99c6c81028bb7bd3cb20abd433cbf396a22 (diff)
downloadPeerTube-a056ca4813c82f490dcd31ac97a64d6bf76d3dcc.tar.gz
PeerTube-a056ca4813c82f490dcd31ac97a64d6bf76d3dcc.tar.zst
PeerTube-a056ca4813c82f490dcd31ac97a64d6bf76d3dcc.zip
Add max lives limit
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video.ts31
1 files changed, 31 insertions, 0 deletions
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<VideoModel> {
1142 return VideoModel.getAvailableForApi(queryOptions) 1142 return VideoModel.getAvailableForApi(queryOptions)
1143 } 1143 }
1144 1144
1145 static countLocalLives () {
1146 const options = {
1147 where: {
1148 remote: false,
1149 isLive: true
1150 }
1151 }
1152
1153 return VideoModel.count(options)
1154 }
1155
1156 static countLivesOfAccount (accountId: number) {
1157 const options = {
1158 where: {
1159 remote: false,
1160 isLive: true
1161 },
1162 include: [
1163 {
1164 required: true,
1165 model: VideoChannelModel.unscoped(),
1166 where: {
1167 accountId
1168 }
1169 }
1170 ]
1171 }
1172
1173 return VideoModel.count(options)
1174 }
1175
1145 static load (id: number | string, t?: Transaction): Bluebird<MVideoThumbnail> { 1176 static load (id: number | string, t?: Transaction): Bluebird<MVideoThumbnail> {
1146 const where = buildWhereIdOrUUID(id) 1177 const where = buildWhereIdOrUUID(id)
1147 const options = { 1178 const options = {