aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-29 10:54:27 +0200
committerChocobozzz <chocobozzz@cpy.re>2021-10-29 11:48:21 +0200
commit3c10840fa90fc88fc98e8169faf4745ff6c80893 (patch)
tree9a60c4de766700fbc33804b06ec46279b20c855e /server/models/video/video.ts
parent2760b454a761f6af3138b2fb5f34340772ab0d1e (diff)
downloadPeerTube-3c10840fa90fc88fc98e8169faf4745ff6c80893.tar.gz
PeerTube-3c10840fa90fc88fc98e8169faf4745ff6c80893.tar.zst
PeerTube-3c10840fa90fc88fc98e8169faf4745ff6c80893.zip
Add video file size info in admin videos list
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts34
1 files changed, 20 insertions, 14 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 26be34329..f9618c102 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -105,7 +105,7 @@ import {
105 videoModelToFormattedJSON 105 videoModelToFormattedJSON
106} from './formatter/video-format-utils' 106} from './formatter/video-format-utils'
107import { ScheduleVideoUpdateModel } from './schedule-video-update' 107import { ScheduleVideoUpdateModel } from './schedule-video-update'
108import { VideosModelGetQueryBuilder } from './sql/video-model-get-query-builder' 108import { VideoModelGetQueryBuilder } from './sql/video-model-get-query-builder'
109import { BuildVideosListQueryOptions, DisplayOnlyForFollowerOptions, VideosIdListQueryBuilder } from './sql/videos-id-list-query-builder' 109import { BuildVideosListQueryOptions, DisplayOnlyForFollowerOptions, VideosIdListQueryBuilder } from './sql/videos-id-list-query-builder'
110import { VideosModelListQueryBuilder } from './sql/videos-model-list-query-builder' 110import { VideosModelListQueryBuilder } from './sql/videos-model-list-query-builder'
111import { TagModel } from './tag' 111import { TagModel } from './tag'
@@ -1029,7 +1029,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1029 isLocal?: boolean 1029 isLocal?: boolean
1030 include?: VideoInclude 1030 include?: VideoInclude
1031 1031
1032 withFiles: boolean 1032 hasFiles?: boolean // default false
1033 1033
1034 categoryOneOf?: number[] 1034 categoryOneOf?: number[]
1035 licenceOneOf?: number[] 1035 licenceOneOf?: number[]
@@ -1053,7 +1053,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1053 1053
1054 search?: string 1054 search?: string
1055 }) { 1055 }) {
1056 if (options.include && !options.user.hasRight(UserRight.SEE_ALL_VIDEOS)) { 1056 if (VideoModel.isPrivateInclude(options.include) && !options.user.hasRight(UserRight.SEE_ALL_VIDEOS)) {
1057 throw new Error('Try to filter all-local but no user has not the see all videos right') 1057 throw new Error('Try to filter all-local but no user has not the see all videos right')
1058 } 1058 }
1059 1059
@@ -1082,7 +1082,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1082 'isLocal', 1082 'isLocal',
1083 'include', 1083 'include',
1084 'displayOnlyForFollower', 1084 'displayOnlyForFollower',
1085 'withFiles', 1085 'hasFiles',
1086 'accountId', 1086 'accountId',
1087 'videoChannelId', 1087 'videoChannelId',
1088 'videoPlaylistId', 1088 'videoPlaylistId',
@@ -1229,13 +1229,13 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1229 } 1229 }
1230 1230
1231 static load (id: number | string, transaction?: Transaction): Promise<MVideoThumbnail> { 1231 static load (id: number | string, transaction?: Transaction): Promise<MVideoThumbnail> {
1232 const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize) 1232 const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)
1233 1233
1234 return queryBuilder.queryVideo({ id, transaction, type: 'thumbnails' }) 1234 return queryBuilder.queryVideo({ id, transaction, type: 'thumbnails' })
1235 } 1235 }
1236 1236
1237 static loadWithBlacklist (id: number | string, transaction?: Transaction): Promise<MVideoThumbnailBlacklist> { 1237 static loadWithBlacklist (id: number | string, transaction?: Transaction): Promise<MVideoThumbnailBlacklist> {
1238 const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize) 1238 const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)
1239 1239
1240 return queryBuilder.queryVideo({ id, transaction, type: 'thumbnails-blacklist' }) 1240 return queryBuilder.queryVideo({ id, transaction, type: 'thumbnails-blacklist' })
1241 } 1241 }
@@ -1279,31 +1279,31 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1279 } 1279 }
1280 1280
1281 static loadOnlyId (id: number | string, transaction?: Transaction): Promise<MVideoId> { 1281 static loadOnlyId (id: number | string, transaction?: Transaction): Promise<MVideoId> {
1282 const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize) 1282 const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)
1283 1283
1284 return queryBuilder.queryVideo({ id, transaction, type: 'id' }) 1284 return queryBuilder.queryVideo({ id, transaction, type: 'id' })
1285 } 1285 }
1286 1286
1287 static loadWithFiles (id: number | string, transaction?: Transaction, logging?: boolean): Promise<MVideoWithAllFiles> { 1287 static loadWithFiles (id: number | string, transaction?: Transaction, logging?: boolean): Promise<MVideoWithAllFiles> {
1288 const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize) 1288 const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)
1289 1289
1290 return queryBuilder.queryVideo({ id, transaction, type: 'all-files', logging }) 1290 return queryBuilder.queryVideo({ id, transaction, type: 'all-files', logging })
1291 } 1291 }
1292 1292
1293 static loadByUrl (url: string, transaction?: Transaction): Promise<MVideoThumbnail> { 1293 static loadByUrl (url: string, transaction?: Transaction): Promise<MVideoThumbnail> {
1294 const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize) 1294 const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)
1295 1295
1296 return queryBuilder.queryVideo({ url, transaction, type: 'thumbnails' }) 1296 return queryBuilder.queryVideo({ url, transaction, type: 'thumbnails' })
1297 } 1297 }
1298 1298
1299 static loadByUrlAndPopulateAccount (url: string, transaction?: Transaction): Promise<MVideoAccountLightBlacklistAllFiles> { 1299 static loadByUrlAndPopulateAccount (url: string, transaction?: Transaction): Promise<MVideoAccountLightBlacklistAllFiles> {
1300 const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize) 1300 const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)
1301 1301
1302 return queryBuilder.queryVideo({ url, transaction, type: 'account-blacklist-files' }) 1302 return queryBuilder.queryVideo({ url, transaction, type: 'account-blacklist-files' })
1303 } 1303 }
1304 1304
1305 static loadAndPopulateAccountAndServerAndTags (id: number | string, t?: Transaction, userId?: number): Promise<MVideoFullLight> { 1305 static loadAndPopulateAccountAndServerAndTags (id: number | string, t?: Transaction, userId?: number): Promise<MVideoFullLight> {
1306 const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize) 1306 const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)
1307 1307
1308 return queryBuilder.queryVideo({ id, transaction: t, type: 'full-light', userId }) 1308 return queryBuilder.queryVideo({ id, transaction: t, type: 'full-light', userId })
1309 } 1309 }
@@ -1314,7 +1314,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1314 userId?: number 1314 userId?: number
1315 }): Promise<MVideoDetails> { 1315 }): Promise<MVideoDetails> {
1316 const { id, transaction, userId } = parameters 1316 const { id, transaction, userId } = parameters
1317 const queryBuilder = new VideosModelGetQueryBuilder(VideoModel.sequelize) 1317 const queryBuilder = new VideoModelGetQueryBuilder(VideoModel.sequelize)
1318 1318
1319 return queryBuilder.queryVideo({ id, transaction, type: 'api', userId }) 1319 return queryBuilder.queryVideo({ id, transaction, type: 'api', userId })
1320 } 1320 }
@@ -1345,8 +1345,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1345 displayOnlyForFollower: { 1345 displayOnlyForFollower: {
1346 actorId: serverActor.id, 1346 actorId: serverActor.id,
1347 orLocalVideos: true 1347 orLocalVideos: true
1348 }, 1348 }
1349 withFiles: false
1350 }) 1349 })
1351 1350
1352 return { 1351 return {
@@ -1490,6 +1489,13 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1490 } 1489 }
1491 } 1490 }
1492 1491
1492 private static isPrivateInclude (include: VideoInclude) {
1493 return include & VideoInclude.BLACKLISTED ||
1494 include & VideoInclude.BLOCKED_OWNER ||
1495 include & VideoInclude.HIDDEN_PRIVACY ||
1496 include & VideoInclude.NOT_PUBLISHED_STATE
1497 }
1498
1493 isBlacklisted () { 1499 isBlacklisted () {
1494 return !!this.VideoBlacklist 1500 return !!this.VideoBlacklist
1495 } 1501 }