X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-channel.ts;h=2c6669bcba9262ef9700502b0b186c47f597b0f3;hb=57a9b61a4aeead74e8800bbfad82ef433313b204;hp=8ccb818b38b111962e378485caa17490e4aa8113;hpb=93a1e67f86be299b7337d229a2c15fbda0a0d6e1;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 8ccb818b3..2c6669bcb 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -17,8 +17,10 @@ import { Table, UpdatedAt } from 'sequelize-typescript' +import { CONFIG } from '@server/initializers/config' import { MAccountActor } from '@server/types/models' -import { AttributesOnly, pick } from '@shared/core-utils' +import { pick } from '@shared/core-utils' +import { AttributesOnly } from '@shared/typescript-utils' import { ActivityPubActor } from '../../../shared/models/activitypub' import { VideoChannel, VideoChannelSummary } from '../../../shared/models/videos' import { @@ -527,7 +529,7 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"` }) } - static listByAccount (options: { + static listByAccountForAPI (options: { accountId: number start: number count: number @@ -582,6 +584,24 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"` }) } + static listAllByAccount (accountId: number) { + const query = { + limit: CONFIG.VIDEO_CHANNELS.MAX_PER_USER, + include: [ + { + attributes: [], + model: AccountModel, + where: { + id: accountId + }, + required: true + } + ] + } + + return VideoChannelModel.findAll(query) + } + static loadAndPopulateAccount (id: number, transaction?: Transaction): Promise { return VideoChannelModel.unscoped() .scope([ ScopeNames.WITH_ACTOR_BANNER, ScopeNames.WITH_ACCOUNT ])