X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-playlist.ts;h=a2dc7075d59587a205b176b641a10bd414fd28b4;hb=fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58;hp=72ba474b40bb80c626b28679983fb532fba715dd;hpb=29837f8885eb37fa300e4b80c90a6d03ab337084;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts index 72ba474b4..a2dc7075d 100644 --- a/server/models/video/video-playlist.ts +++ b/server/models/video/video-playlist.ts @@ -17,7 +17,6 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { setAsUpdated } from '@server/helpers/database-utils' import { buildUUID, uuidToShort } from '@server/helpers/uuid' import { MAccountId, MChannelId } from '@server/types/models' import { AttributesOnly, buildPlaylistEmbedPath, buildPlaylistWatchPath } from '@shared/core-utils' @@ -53,6 +52,7 @@ import { } from '../../types/models/video/video-playlist' import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions } from '../account/account' import { ActorModel } from '../actor/actor' +import { setAsUpdated } from '../shared' import { buildServerIdsFollowedBy, buildTrigramSearchIndex, @@ -82,6 +82,7 @@ type AvailableForListOptions = { videoChannelId?: number listMyPlaylists?: boolean search?: string + host?: string withVideos?: boolean } @@ -141,9 +142,19 @@ function getVideoLengthSelect () { ] }, [ScopeNames.AVAILABLE_FOR_LIST]: (options: AvailableForListOptions) => { + const whereAnd: WhereOptions[] = [] + + const whereServer = options.host && options.host !== WEBSERVER.HOST + ? { host: options.host } + : undefined + let whereActor: WhereOptions = {} - const whereAnd: WhereOptions[] = [] + if (options.host === WEBSERVER.HOST) { + whereActor = { + [Op.and]: [ { serverId: null } ] + } + } if (options.listMyPlaylists !== true) { whereAnd.push({ @@ -168,9 +179,7 @@ function getVideoLengthSelect () { }) } - whereActor = { - [Op.or]: whereActorOr - } + Object.assign(whereActor, { [Op.or]: whereActorOr }) } if (options.accountId) { @@ -228,7 +237,7 @@ function getVideoLengthSelect () { include: [ { model: AccountModel.scope({ - method: [ AccountScopeNames.SUMMARY, { whereActor } as SummaryOptions ] + method: [ AccountScopeNames.SUMMARY, { whereActor, whereServer } as SummaryOptions ] }), required: true }, @@ -349,6 +358,7 @@ export class VideoPlaylistModel extends Model