Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Playlist podcast feed can see unlisted videos

Chocobozzz4d328d9b6cbf
diff --git a/packages/tests/src/feeds/feeds.ts b/packages/tests/src/feeds/feeds.ts
index ae30738838..33425f6a8e 100644
--- a/packages/tests/src/feeds/feeds.ts
+++ b/packages/tests/src/feeds/feeds.ts
@@ -450,6 +450,25 @@ describe('Test syndication feeds', () => {
expect(items[0].title).to.equal('my super name for server 1')
})
+ it('Should contain unlisted videos', async function () {
+ const unlisted = await servers[0].videos.quickUpload({ name: 'unlisted video for playlist', privacy: VideoPrivacy.UNLISTED })
+ await servers[0].playlists.addElement({ playlistId: podcastPlaylistId, attributes: { videoId: unlisted.id } })
+
+ const rss = await servers[0].feed.getPodcastXML({ ignoreCache: false, playlistId: podcastPlaylistId })
+ const parser = new XMLParser({ parseAttributeValue: true, ignoreAttributes: false })
+ const xmlDoc = parser.parse(rss)
+
+ const items = Array.isArray(xmlDoc.rss.channel.item)
+ ? xmlDoc.rss.channel.item
+ : [ xmlDoc.rss.channel.item ]
+
+ expect(items.length).to.equal(2)
+ expect(items.some((i: any) => i.title === 'unlisted video for playlist')).to.equal(true)
+
+ await servers[0].videos.remove({ id: unlisted.id })
+ await waitJobs(servers[0])
+ })
+
it('Should have valid itunes metadata', async function () {
const channel = xmlDoc.rss.channel
diff --git a/server/core/controllers/feeds/shared/video-feed-utils.ts b/server/core/controllers/feeds/shared/video-feed-utils.ts
index 8bed986a33..19e516ea77 100644
--- a/server/core/controllers/feeds/shared/video-feed-utils.ts
+++ b/server/core/controllers/feeds/shared/video-feed-utils.ts
@@ -1,5 +1,5 @@
import { getChannelPodcastFeed, getPlaylistPodcastFeed } from '@peertube/peertube-core-utils'
-import { VideoIncludeType } from '@peertube/peertube-models'
+import { VideoIncludeType, VideoPrivacy } from '@peertube/peertube-models'
import { mdToPlainText, toSafeHtml } from '@server/helpers/markdown.js'
import { CONFIG } from '@server/initializers/config.js'
import { WEBSERVER } from '@server/initializers/constants.js'
@@ -16,6 +16,7 @@ export async function getVideosForFeeds (options: {
isLocal: boolean
include: VideoIncludeType
+ allowUnlisted?: boolean // Default false
accountId?: number
videoChannelId?: number
videoPlaylistId?: number
@@ -36,6 +37,11 @@ export async function getVideosForFeeds (options: {
hasFiles: true,
countVideos: false,
+ privacyOneOf: options.allowUnlisted
+ ? [ VideoPrivacy.PUBLIC, VideoPrivacy.UNLISTED ]
+ : [ VideoPrivacy.PUBLIC ],
+ skipPrivateIncludeCheck: true,
+
...options
},
'filter:feed.videos.list.result'
diff --git a/server/core/controllers/feeds/video-podcast-feeds.ts b/server/core/controllers/feeds/video-podcast-feeds.ts
index 3cb1261c6e..5531231eeb 100644
--- a/server/core/controllers/feeds/video-podcast-feeds.ts
+++ b/server/core/controllers/feeds/video-podcast-feeds.ts
@@ -187,7 +187,8 @@ async function generatePlaylistPodcastFeed (req: express.Request, res: express.R
// helps prevent duplicates when they are indexed -- only the author should control them
isLocal: true,
include: VideoInclude.FILES,
- videoPlaylistId: playlist.id
+ videoPlaylistId: playlist.id,
+ allowUnlisted: true // Playlists should be able to list unlisted videos, otherwise they are not really usable
})
const language = await VideoModel.guessLanguageOrCategoryOf('language', { videoPlaylistId: playlist.id })