Display playlists if allowed to escape federation
This commit is contained in:
parent
3f8454ce63
commit
5ef0430dfb
|
@ -188,7 +188,11 @@ async function listAccountPlaylists (req: express.Request, res: express.Response
|
||||||
|
|
||||||
const resultList = await VideoPlaylistModel.listForApi({
|
const resultList = await VideoPlaylistModel.listForApi({
|
||||||
search: req.query.search,
|
search: req.query.search,
|
||||||
followerActorId: serverActor.id,
|
|
||||||
|
followerActorId: isUserAbleToSearchRemoteURI(res)
|
||||||
|
? null
|
||||||
|
: serverActor.id,
|
||||||
|
|
||||||
start: req.query.start,
|
start: req.query.start,
|
||||||
count: req.query.count,
|
count: req.query.count,
|
||||||
sort: req.query.sort,
|
sort: req.query.sort,
|
||||||
|
|
|
@ -140,6 +140,7 @@ videoChannelRouter.get('/:nameWithHost',
|
||||||
)
|
)
|
||||||
|
|
||||||
videoChannelRouter.get('/:nameWithHost/video-playlists',
|
videoChannelRouter.get('/:nameWithHost/video-playlists',
|
||||||
|
optionalAuthenticate,
|
||||||
asyncMiddleware(videoChannelsNameWithHostValidator),
|
asyncMiddleware(videoChannelsNameWithHostValidator),
|
||||||
paginationValidator,
|
paginationValidator,
|
||||||
videoPlaylistsSortValidator,
|
videoPlaylistsSortValidator,
|
||||||
|
@ -372,7 +373,10 @@ async function listVideoChannelPlaylists (req: express.Request, res: express.Res
|
||||||
const serverActor = await getServerActor()
|
const serverActor = await getServerActor()
|
||||||
|
|
||||||
const resultList = await VideoPlaylistModel.listForApi({
|
const resultList = await VideoPlaylistModel.listForApi({
|
||||||
followerActorId: serverActor.id,
|
followerActorId: isUserAbleToSearchRemoteURI(res)
|
||||||
|
? null
|
||||||
|
: serverActor.id,
|
||||||
|
|
||||||
start: req.query.start,
|
start: req.query.start,
|
||||||
count: req.query.count,
|
count: req.query.count,
|
||||||
sort: req.query.sort,
|
sort: req.query.sort,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import express from 'express'
|
|
||||||
import { forceNumber } from '@peertube/peertube-core-utils'
|
import { forceNumber } from '@peertube/peertube-core-utils'
|
||||||
import {
|
import {
|
||||||
HttpStatusCode,
|
HttpStatusCode,
|
||||||
|
@ -12,11 +11,13 @@ import {
|
||||||
VideoPlaylistReorder,
|
VideoPlaylistReorder,
|
||||||
VideoPlaylistUpdate
|
VideoPlaylistUpdate
|
||||||
} from '@peertube/peertube-models'
|
} from '@peertube/peertube-models'
|
||||||
|
import { uuidToShort } from '@peertube/peertube-node-utils'
|
||||||
import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists/index.js'
|
import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists/index.js'
|
||||||
import { Hooks } from '@server/lib/plugins/hooks.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 { getServerActor } from '@server/models/application/application.js'
|
||||||
import { MVideoPlaylistFull, MVideoPlaylistThumbnail } from '@server/types/models/index.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 { resetSequelizeInstance } from '../../helpers/database-utils.js'
|
||||||
import { createReqFiles } from '../../helpers/express-utils.js'
|
import { createReqFiles } from '../../helpers/express-utils.js'
|
||||||
import { logger } from '../../helpers/logger.js'
|
import { logger } from '../../helpers/logger.js'
|
||||||
|
@ -50,7 +51,6 @@ import {
|
||||||
import { AccountModel } from '../../models/account/account.js'
|
import { AccountModel } from '../../models/account/account.js'
|
||||||
import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element.js'
|
import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element.js'
|
||||||
import { VideoPlaylistModel } from '../../models/video/video-playlist.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)
|
const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { buildUUID, uuidToShort } from '@peertube/peertube-node-utils'
|
||||||
import { activityPubCollectionPagination } from '@server/lib/activitypub/collection.js'
|
import { activityPubCollectionPagination } from '@server/lib/activitypub/collection.js'
|
||||||
import { MAccountId, MChannelId, MVideoPlaylistElement } from '@server/types/models/index.js'
|
import { MAccountId, MChannelId, MVideoPlaylistElement } from '@server/types/models/index.js'
|
||||||
import { join } from 'path'
|
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 {
|
import {
|
||||||
AllowNull,
|
AllowNull,
|
||||||
BelongsTo,
|
BelongsTo,
|
||||||
|
@ -47,8 +47,9 @@ import {
|
||||||
import { MThumbnail } from '../../types/models/video/thumbnail.js'
|
import { MThumbnail } from '../../types/models/video/thumbnail.js'
|
||||||
import {
|
import {
|
||||||
MVideoPlaylist,
|
MVideoPlaylist,
|
||||||
|
MVideoPlaylistAP,
|
||||||
MVideoPlaylistAccountThumbnail,
|
MVideoPlaylistAccountThumbnail,
|
||||||
MVideoPlaylistAP, MVideoPlaylistFormattable,
|
MVideoPlaylistFormattable,
|
||||||
MVideoPlaylistFull,
|
MVideoPlaylistFull,
|
||||||
MVideoPlaylistFullSummary,
|
MVideoPlaylistFullSummary,
|
||||||
MVideoPlaylistSummaryWithElements
|
MVideoPlaylistSummaryWithElements
|
||||||
|
@ -167,15 +168,15 @@ function getVideoLengthSelect () {
|
||||||
privacy: VideoPlaylistPrivacy.PUBLIC
|
privacy: VideoPlaylistPrivacy.PUBLIC
|
||||||
})
|
})
|
||||||
|
|
||||||
// Only list local playlists
|
|
||||||
const whereActorOr: WhereOptions[] = [
|
|
||||||
{
|
|
||||||
serverId: null
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
// … OR playlists that are on an instance followed by actorId
|
// … OR playlists that are on an instance followed by actorId
|
||||||
if (options.followerActorId) {
|
if (options.followerActorId) {
|
||||||
|
// Only list local playlists
|
||||||
|
const whereActorOr: WhereOptions[] = [
|
||||||
|
{
|
||||||
|
serverId: null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
const inQueryInstanceFollow = buildServerIdsFollowedBy(options.followerActorId)
|
const inQueryInstanceFollow = buildServerIdsFollowedBy(options.followerActorId)
|
||||||
|
|
||||||
whereActorOr.push({
|
whereActorOr.push({
|
||||||
|
@ -183,9 +184,9 @@ function getVideoLengthSelect () {
|
||||||
[Op.in]: literal(inQueryInstanceFollow)
|
[Op.in]: literal(inQueryInstanceFollow)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
Object.assign(whereActor, { [Op.or]: whereActorOr })
|
Object.assign(whereActor, { [Op.or]: whereActorOr })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.accountId) {
|
if (options.accountId) {
|
||||||
|
|
Loading…
Reference in New Issue