Display playlists if allowed to escape federation

This commit is contained in:
Chocobozzz 2024-03-27 15:48:29 +01:00
parent 3f8454ce63
commit 5ef0430dfb
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 25 additions and 16 deletions

View File

@ -188,7 +188,11 @@ async function listAccountPlaylists (req: express.Request, res: express.Response
const resultList = await VideoPlaylistModel.listForApi({
search: req.query.search,
followerActorId: serverActor.id,
followerActorId: isUserAbleToSearchRemoteURI(res)
? null
: serverActor.id,
start: req.query.start,
count: req.query.count,
sort: req.query.sort,

View File

@ -140,6 +140,7 @@ videoChannelRouter.get('/:nameWithHost',
)
videoChannelRouter.get('/:nameWithHost/video-playlists',
optionalAuthenticate,
asyncMiddleware(videoChannelsNameWithHostValidator),
paginationValidator,
videoPlaylistsSortValidator,
@ -372,7 +373,10 @@ async function listVideoChannelPlaylists (req: express.Request, res: express.Res
const serverActor = await getServerActor()
const resultList = await VideoPlaylistModel.listForApi({
followerActorId: serverActor.id,
followerActorId: isUserAbleToSearchRemoteURI(res)
? null
: serverActor.id,
start: req.query.start,
count: req.query.count,
sort: req.query.sort,

View File

@ -1,4 +1,3 @@
import express from 'express'
import { forceNumber } from '@peertube/peertube-core-utils'
import {
HttpStatusCode,
@ -12,11 +11,13 @@ import {
VideoPlaylistReorder,
VideoPlaylistUpdate
} from '@peertube/peertube-models'
import { uuidToShort } from '@peertube/peertube-node-utils'
import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists/index.js'
import { Hooks } from '@server/lib/plugins/hooks.js'
import { generateThumbnailForPlaylist } from '@server/lib/video-playlist.js'
import { getServerActor } from '@server/models/application/application.js'
import { MVideoPlaylistFull, MVideoPlaylistThumbnail } from '@server/types/models/index.js'
import { uuidToShort } from '@peertube/peertube-node-utils'
import express from 'express'
import { resetSequelizeInstance } from '../../helpers/database-utils.js'
import { createReqFiles } from '../../helpers/express-utils.js'
import { logger } from '../../helpers/logger.js'
@ -50,7 +51,6 @@ import {
import { AccountModel } from '../../models/account/account.js'
import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element.js'
import { VideoPlaylistModel } from '../../models/video/video-playlist.js'
import { generateThumbnailForPlaylist } from '@server/lib/video-playlist.js'
const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT)

View File

@ -12,7 +12,7 @@ import { buildUUID, uuidToShort } from '@peertube/peertube-node-utils'
import { activityPubCollectionPagination } from '@server/lib/activitypub/collection.js'
import { MAccountId, MChannelId, MVideoPlaylistElement } from '@server/types/models/index.js'
import { join } from 'path'
import { FindOptions, Includeable, literal, Op, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize'
import { FindOptions, Includeable, Op, ScopeOptions, Sequelize, Transaction, WhereOptions, literal } from 'sequelize'
import {
AllowNull,
BelongsTo,
@ -47,8 +47,9 @@ import {
import { MThumbnail } from '../../types/models/video/thumbnail.js'
import {
MVideoPlaylist,
MVideoPlaylistAP,
MVideoPlaylistAccountThumbnail,
MVideoPlaylistAP, MVideoPlaylistFormattable,
MVideoPlaylistFormattable,
MVideoPlaylistFull,
MVideoPlaylistFullSummary,
MVideoPlaylistSummaryWithElements
@ -167,6 +168,8 @@ function getVideoLengthSelect () {
privacy: VideoPlaylistPrivacy.PUBLIC
})
// … OR playlists that are on an instance followed by actorId
if (options.followerActorId) {
// Only list local playlists
const whereActorOr: WhereOptions[] = [
{
@ -174,8 +177,6 @@ function getVideoLengthSelect () {
}
]
// … OR playlists that are on an instance followed by actorId
if (options.followerActorId) {
const inQueryInstanceFollow = buildServerIdsFollowedBy(options.followerActorId)
whereActorOr.push({
@ -183,10 +184,10 @@ function getVideoLengthSelect () {
[Op.in]: literal(inQueryInstanceFollow)
}
})
}
Object.assign(whereActor, { [Op.or]: whereActorOr })
}
}
if (options.accountId) {
whereAnd.push({