1
0
Fork 0

Disallow unlisted video indexation

This commit is contained in:
Chocobozzz 2022-04-08 16:26:38 +02:00
parent 1575be6825
commit c6d20c84a7
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 61 additions and 2 deletions

View File

@ -134,6 +134,7 @@ class ClientHtml {
escapedSiteName: escapeHTML(siteName),
escapedTitle: escapeHTML(title),
escapedDescription: escapeHTML(description),
disallowIndexation: video.privacy !== VideoPrivacy.PUBLIC,
image,
embed,
ogType,
@ -197,6 +198,7 @@ class ClientHtml {
escapedSiteName: escapeHTML(siteName),
escapedTitle: escapeHTML(title),
escapedDescription: escapeHTML(description),
disallowIndexation: videoPlaylist.privacy !== VideoPlaylistPrivacy.PUBLIC,
embed,
image,
list,

View File

@ -3,7 +3,7 @@
import 'mocha'
import * as chai from 'chai'
import { omit } from 'lodash'
import { Account, HTMLServerConfig, HttpStatusCode, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models'
import { Account, HTMLServerConfig, HttpStatusCode, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
@ -48,6 +48,10 @@ describe('Test a client controllers', function () {
const watchPlaylistBasePaths = [ '/videos/watch/playlist/', '/w/p/' ]
let videoIds: (string | number)[] = []
let privateVideoId: string
let internalVideoId: string
let unlistedVideoId: string
let playlistIds: (string | number)[] = []
before(async function () {
@ -66,7 +70,7 @@ describe('Test a client controllers', function () {
attributes: { description: channelDescription }
})
// Video
// Public video
{
const attributes = { name: videoName, description: videoDescription }
@ -80,6 +84,12 @@ describe('Test a client controllers', function () {
videoIds = [ video.id, video.uuid, video.shortUUID ]
}
{
({ uuid: privateVideoId } = await servers[0].videos.quickUpload({ name: 'private', privacy: VideoPrivacy.PRIVATE }));
({ uuid: unlistedVideoId } = await servers[0].videos.quickUpload({ name: 'unlisted', privacy: VideoPrivacy.UNLISTED }));
({ uuid: internalVideoId } = await servers[0].videos.quickUpload({ name: 'internal', privacy: VideoPrivacy.INTERNAL }))
}
// Playlist
{
@ -466,6 +476,53 @@ describe('Test a client controllers', function () {
}
})
it('Should add noindex meta tag for remote channels', async function () {
const handle = 'root_channel@' + servers[0].host
const paths = [ '/video-channels/', '/c/', '/@' ]
for (const path of paths) {
{
const { text } = await makeHTMLRequest(servers[1].url, path + handle)
expect(text).to.contain('<meta name="robots" content="noindex" />')
}
{
const { text } = await makeHTMLRequest(servers[0].url, path + handle)
expect(text).to.not.contain('<meta name="robots" content="noindex" />')
}
}
})
it('Should not display internal/private video', async function () {
for (const basePath of watchVideoBasePaths) {
for (const id of [ privateVideoId, internalVideoId ]) {
const res = await makeGetRequest({
url: servers[0].url,
path: basePath + id,
accept: 'text/html',
expectedStatus: HttpStatusCode.NOT_FOUND_404
})
expect(res.text).to.not.contain('internal')
expect(res.text).to.not.contain('private')
}
}
})
it('Should add noindex meta tag for unlisted video', async function () {
for (const basePath of watchVideoBasePaths) {
const res = await makeGetRequest({
url: servers[0].url,
path: basePath + unlistedVideoId,
accept: 'text/html',
expectedStatus: HttpStatusCode.OK_200
})
expect(res.text).to.contain('unlisted')
expect(res.text).to.contain('<meta name="robots" content="noindex" />')
}
})
it('Should add noindex meta tag for remote accounts', async function () {
const handle = 'root_channel@' + servers[0].host
const paths = [ '/video-channels/', '/c/', '/@' ]