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'
} 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,
videoChannelId?: number
listMyPlaylists?: boolean
search?: string
+ host?: string
withVideos?: boolean
}
]
},
[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({
})
}
- whereActor = {
- [Op.or]: whereActorOr
- }
+ Object.assign(whereActor, { [Op.or]: whereActorOr })
}
if (options.accountId) {
include: [
{
model: AccountModel.scope({
- method: [ AccountScopeNames.SUMMARY, { whereActor } as SummaryOptions ]
+ method: [ AccountScopeNames.SUMMARY, { whereActor, whereServer } as SummaryOptions ]
}),
required: true
},
videoChannelId?: number
listMyPlaylists?: boolean
search?: string
+ host?: string
withVideos?: boolean // false by default
}) {
const query = {
videoChannelId: options.videoChannelId,
listMyPlaylists: options.listMyPlaylists,
search: options.search,
+ host: options.host,
withVideos: options.withVideos || false
} as AvailableForListOptions
]
count: number
sort: string
search?: string
+ host?: string
}) {
return VideoPlaylistModel.listForApi({
...options,