X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo.ts;h=c0a7892a430f12f354671b6919c0e9edb54d0d07;hb=86aafd06f2d124786ea3d10477f356c2e3f85dd6;hp=18f18795ed653802d5cb9d82dde5ba067bf5b7b0;hpb=3acc50844047a37698f0618fa235c138e386a053;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 18f18795e..c0a7892a4 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -207,6 +207,8 @@ type AvailableForListIDsOptions = { followerActorId: number includeLocalVideos: boolean + withoutId?: boolean + filter?: VideoFilter categoryOneOf?: number[] nsfw?: boolean @@ -239,6 +241,11 @@ type AvailableForListIDsOptions = { { model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, true ] }), required: true + }, + { + attributes: [ 'type', 'filename' ], + model: ThumbnailModel, + required: false } ] } @@ -263,9 +270,11 @@ type AvailableForListIDsOptions = { return query }, [ ScopeNames.AVAILABLE_FOR_LIST_IDS ]: (options: AvailableForListIDsOptions) => { + const attributes = options.withoutId === true ? [] : [ 'id' ] + const query: FindOptions = { raw: true, - attributes: [ 'id' ], + attributes, where: { id: { [ Op.and ]: [ @@ -1117,15 +1126,11 @@ export class VideoModel extends Model { const countQuery = buildBaseQuery() const findQuery = buildBaseQuery() - findQuery.include.push({ - model: ScheduleVideoUpdateModel, - required: false - }) - - findQuery.include.push({ - model: VideoBlacklistModel, - required: false - }) + const findScopes = [ + ScopeNames.WITH_SCHEDULED_UPDATE, + ScopeNames.WITH_BLACKLISTED, + ScopeNames.WITH_THUMBNAILS + ] if (withFiles === true) { findQuery.include.push({ @@ -1136,7 +1141,7 @@ export class VideoModel extends Model { return Promise.all([ VideoModel.count(countQuery), - VideoModel.findAll(findQuery) + VideoModel.scope(findScopes).findAll(findQuery) ]).then(([ count, rows ]) => { return { data: rows, @@ -1518,7 +1523,8 @@ export class VideoModel extends Model { const scopeOptions: AvailableForListIDsOptions = { serverAccountId: serverActor.Account.id, followerActorId, - includeLocalVideos: true + includeLocalVideos: true, + withoutId: true // Don't break aggregation } const query: FindOptions = { @@ -1599,7 +1605,7 @@ export class VideoModel extends Model { ] } - const apiScope: (string | ScopeOptions)[] = [ ScopeNames.WITH_THUMBNAILS ] + const apiScope: (string | ScopeOptions)[] = [] if (options.user) { apiScope.push({ method: [ ScopeNames.WITH_USER_HISTORY, options.user.id ] })