From 655c957cc3004c4b4841538486f009511573cdf2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 8 Oct 2021 11:06:02 +0200 Subject: [PATCH 01/13] Stop indexing /about/peertube --- server/controllers/client.ts | 10 ++++++++-- server/controllers/static.ts | 1 + server/middlewares/index.ts | 1 + server/middlewares/robots.ts | 13 +++++++++++++ server/tests/client.ts | 10 ++++++++++ 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 server/middlewares/robots.ts diff --git a/server/controllers/client.ts b/server/controllers/client.ts index d81e35ec3..cdc556da2 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts @@ -5,12 +5,12 @@ import { join } from 'path' import { logger } from '@server/helpers/logger' import { CONFIG } from '@server/initializers/config' import { Hooks } from '@server/lib/plugins/hooks' -import { HttpStatusCode } from '@shared/models' import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '@shared/core-utils/i18n' +import { HttpStatusCode } from '@shared/models' import { root } from '../helpers/core-utils' import { STATIC_MAX_AGE } from '../initializers/constants' import { ClientHtml, sendHTML, serveIndexHTML } from '../lib/client-html' -import { asyncMiddleware, embedCSP } from '../middlewares' +import { asyncMiddleware, disableRobots, embedCSP } from '../middlewares' const clientsRouter = express.Router() @@ -81,6 +81,12 @@ clientsRouter.use('/client/*', (req: express.Request, res: express.Response) => res.status(HttpStatusCode.NOT_FOUND_404).end() }) +// No index exceptions +clientsRouter.all('/about/peertube', + disableRobots, + asyncMiddleware(serveIndexHTML) +) + // Always serve index client page (the client is a single page application, let it handle routing) // Try to provide the right language index.html clientsRouter.use('/(:language)?', asyncMiddleware(serveIndexHTML)) diff --git a/server/controllers/static.ts b/server/controllers/static.ts index 1c04e4b11..fe1629910 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts @@ -69,6 +69,7 @@ staticRouter.get('/robots.txt', cacheRoute(ROUTE_CACHE_LIFETIME.ROBOTS), (_, res: express.Response) => { res.type('text/plain') + return res.send(CONFIG.INSTANCE.ROBOTS) } ) diff --git a/server/middlewares/index.ts b/server/middlewares/index.ts index a0035f623..d2ed079b6 100644 --- a/server/middlewares/index.ts +++ b/server/middlewares/index.ts @@ -4,6 +4,7 @@ export * from './activitypub' export * from './async' export * from './auth' export * from './pagination' +export * from './robots' export * from './servers' export * from './sort' export * from './user-right' diff --git a/server/middlewares/robots.ts b/server/middlewares/robots.ts new file mode 100644 index 000000000..b22b24a9f --- /dev/null +++ b/server/middlewares/robots.ts @@ -0,0 +1,13 @@ +import express from 'express' + +function disableRobots (req: express.Request, res: express.Response, next: express.NextFunction) { + res.setHeader('X-Robots-Tag', 'noindex') + + return next() +} + +// --------------------------------------------------------------------------- + +export { + disableRobots +} diff --git a/server/tests/client.ts b/server/tests/client.ts index a91bec906..6c32c81db 100644 --- a/server/tests/client.ts +++ b/server/tests/client.ts @@ -482,6 +482,16 @@ describe('Test a client controllers', function () { } } }) + + it('Should add noindex header for some paths', async function () { + const paths = [ '/about/peertube' ] + + for (const path of paths) { + const { headers } = await makeHTMLRequest(servers[0].url, path) + + expect(headers['x-robots-tag']).to.equal('noindex') + } + }) }) describe('Embed HTML', function () { From b0268e27e1584d7afcaa3411df454c68130787be Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 8 Oct 2021 11:15:06 +0200 Subject: [PATCH 02/13] Fix channel search with complete handle --- server/models/video/video-channel.ts | 2 +- server/tests/api/search/search-channels.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index c04bd4355..8ccb818b3 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -121,7 +121,7 @@ export type SummaryOptions = { for (const handle of options.handles || []) { const [ preferredUsername, host ] = handle.split('@') - if (!host) { + if (!host || host === WEBSERVER.HOST) { or.push({ '$Actor.preferredUsername$': preferredUsername, '$Actor.serverId$': null diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts index 8a01aff90..67612537c 100644 --- a/server/tests/api/search/search-channels.ts +++ b/server/tests/api/search/search-channels.ts @@ -128,6 +128,13 @@ describe('Test channels search', function () { expect(body.data[0].displayName).to.equal('Squall channel') } + { + const body = await command.advancedChannelSearch({ search: { handles: [ 'squall_channel@' + server.host ] } }) + expect(body.total).to.equal(1) + expect(body.data).to.have.lengthOf(1) + expect(body.data[0].displayName).to.equal('Squall channel') + } + { const body = await command.advancedChannelSearch({ search: { handles: [ 'chocobozzz_channel' ] } }) expect(body.total).to.equal(0) From 9da443f374d9f845331435ce3423ad16e5ac331d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 8 Oct 2021 11:22:22 +0200 Subject: [PATCH 03/13] Remove unused comments --- server/helpers/regexp.ts | 1 - server/initializers/migrations/0135-video-channel-actor.ts | 1 - shared/extra-utils/miscs/sql-command.ts | 1 - 3 files changed, 3 deletions(-) diff --git a/server/helpers/regexp.ts b/server/helpers/regexp.ts index cfc2be488..257054cea 100644 --- a/server/helpers/regexp.ts +++ b/server/helpers/regexp.ts @@ -4,7 +4,6 @@ function regexpCapture (str: string, regex: RegExp, maxIterations = 100) { let m: RegExpExecArray let i = 0 - // tslint:disable:no-conditional-assignment while ((m = regex.exec(str)) !== null && i < maxIterations) { // This is necessary to avoid infinite loops with zero-width matches if (m.index === regex.lastIndex) { diff --git a/server/initializers/migrations/0135-video-channel-actor.ts b/server/initializers/migrations/0135-video-channel-actor.ts index 3f620dfa3..6989e1cbb 100644 --- a/server/initializers/migrations/0135-video-channel-actor.ts +++ b/server/initializers/migrations/0135-video-channel-actor.ts @@ -56,7 +56,6 @@ async function up (utils: { } { - // tslint:disable:no-trailing-whitespace const query1 = ` INSERT INTO "actor" diff --git a/shared/extra-utils/miscs/sql-command.ts b/shared/extra-utils/miscs/sql-command.ts index 80c8cd271..bedb3349b 100644 --- a/shared/extra-utils/miscs/sql-command.ts +++ b/shared/extra-utils/miscs/sql-command.ts @@ -50,7 +50,6 @@ export class SQLCommand extends AbstractCommand { async countVideoViewsOf (uuid: string) { const seq = this.getSequelize() - // tslint:disable const query = 'SELECT SUM("videoView"."views") AS "total" FROM "videoView" ' + `INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'` From 8e7442d0d818ef25240b46dd1115187c7c042a3a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 8 Oct 2021 11:26:17 +0200 Subject: [PATCH 04/13] Fix autoblock message on upload page --- client/src/app/+videos/+video-edit/video-add.component.html | 2 +- client/src/app/+videos/+video-edit/video-add.component.ts | 2 +- client/src/app/core/users/user.model.ts | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/app/+videos/+video-edit/video-add.component.html b/client/src/app/+videos/+video-edit/video-add.component.html index 7dd9ba357..29cf08e75 100644 --- a/client/src/app/+videos/+video-edit/video-add.component.html +++ b/client/src/app/+videos/+video-edit/video-add.component.html @@ -15,7 +15,7 @@ -
+
{{ uploadMessages.autoBlock }}
diff --git a/client/src/app/+videos/+video-edit/video-add.component.ts b/client/src/app/+videos/+video-edit/video-add.component.ts index 46881be4e..bcb2fc4fa 100644 --- a/client/src/app/+videos/+video-edit/video-add.component.ts +++ b/client/src/app/+videos/+video-edit/video-add.component.ts @@ -43,7 +43,7 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate { hasNoQuotaLeft = false hasNoQuotaLeftDaily = false - private serverConfig: HTMLServerConfig + serverConfig: HTMLServerConfig constructor ( private auth: AuthService, diff --git a/client/src/app/core/users/user.model.ts b/client/src/app/core/users/user.model.ts index 00078af5d..c0e5d3169 100644 --- a/client/src/app/core/users/user.model.ts +++ b/client/src/app/core/users/user.model.ts @@ -2,6 +2,7 @@ import { Account } from '@app/shared/shared-main/account/account.model' import { hasUserRight } from '@shared/core-utils/users' import { ActorImage, + HTMLServerConfig, NSFWPolicyType, User as UserServerModel, UserAdminFlag, @@ -136,7 +137,9 @@ export class User implements UserServerModel { return this.videoQuota === 0 || this.videoQuotaDaily === 0 } - isAutoBlocked () { + isAutoBlocked (serverConfig: HTMLServerConfig) { + if (serverConfig.autoBlacklist.videos.ofUsers.enabled !== true) return false + return this.role === UserRole.USER && this.adminFlags !== UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST } } From dd0ad8dfa5a4cdab066602668ed182cb45098e10 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 8 Oct 2021 11:57:39 +0200 Subject: [PATCH 05/13] Fix local/session storage polyfill --- client/src/root-helpers/peertube-web-storage.ts | 16 +++++++--------- client/src/standalone/videos/test-embed.ts | 2 ++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/client/src/root-helpers/peertube-web-storage.ts b/client/src/root-helpers/peertube-web-storage.ts index 68a2462de..0bbe2c9fc 100644 --- a/client/src/root-helpers/peertube-web-storage.ts +++ b/client/src/root-helpers/peertube-web-storage.ts @@ -6,19 +6,17 @@ function proxify (instance: MemoryStorage) { return new Proxy(instance, { set: function (obj, prop: string | symbol, value) { if (Object.prototype.hasOwnProperty.call(MemoryStorage, prop)) { - // FIXME: symbol typing issue https://github.com/microsoft/TypeScript/issues/1863 - instance[prop as any] = value + instance[prop] = value } else { instance.setItem(prop, value) } + return true }, get: function (target, name: string | symbol | number) { - if (Object.prototype.hasOwnProperty.call(MemoryStorage, name)) { - // FIXME: symbol typing issue https://github.com/microsoft/TypeScript/issues/1863 - return instance[name as any] - } - if (valuesMap.has(name)) { + if (typeof instance[name] === 'function') { + return instance[name] + } else if (valuesMap.has(name)) { return instance.getItem(name) } } @@ -26,7 +24,7 @@ function proxify (instance: MemoryStorage) { } class MemoryStorage implements Storage { - [key: string]: any + [key: string | symbol]: any getItem (key: any) { const stringKey = String(key) @@ -83,7 +81,7 @@ try { } // support Brave and other browsers using null rather than an exception -if (peertubeLocalStorage === null || peertubeSessionStorage === null) { +if (!peertubeLocalStorage || !peertubeSessionStorage) { reinitStorage() } diff --git a/client/src/standalone/videos/test-embed.ts b/client/src/standalone/videos/test-embed.ts index 301c95d7b..a28a83cc1 100644 --- a/client/src/standalone/videos/test-embed.ts +++ b/client/src/standalone/videos/test-embed.ts @@ -15,6 +15,8 @@ window.addEventListener('load', async () => { ? `/video-playlists/embed/${elementId}?api=1` : `/videos/embed/${elementId}?api=1` + iframe.sandbox.add('allow-same-origin', 'allow-scripts', 'allow-popups') + const mainElement = document.querySelector('#host') mainElement.appendChild(iframe) From 7d786e5c1621e1aa41db1d6e7244f16df7343d45 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 8 Oct 2021 14:49:15 +0200 Subject: [PATCH 06/13] Handle oembed with params in URL --- server/middlewares/validators/oembed.ts | 16 ++++++- server/tests/api/server/services.ts | 58 +++++++++++++------------ 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts index 5e47211b5..96c8adc99 100644 --- a/server/middlewares/validators/oembed.ts +++ b/server/middlewares/validators/oembed.ts @@ -62,12 +62,26 @@ const oembedValidator = [ const url = req.query.url as string + let urlPath: string + + try { + urlPath = new URL(url).pathname + } catch (err) { + return res.fail({ + status: HttpStatusCode.BAD_REQUEST_400, + message: err.message, + data: { + url + } + }) + } + const isPlaylist = startPlaylistURLs.some(u => url.startsWith(u)) const isVideo = isPlaylist ? false : startVideoURLs.some(u => url.startsWith(u)) const startIsOk = isVideo || isPlaylist - const matches = watchRegex.exec(url) + const matches = watchRegex.exec(urlPath) if (startIsOk === false || matches === null) { return res.fail({ diff --git a/server/tests/api/server/services.ts b/server/tests/api/server/services.ts index 69d030dbb..3a87df981 100644 --- a/server/tests/api/server/services.ts +++ b/server/tests/api/server/services.ts @@ -52,42 +52,46 @@ describe('Test services', function () { it('Should have a valid oEmbed video response', async function () { for (const basePath of [ '/videos/watch/', '/w/' ]) { - const oembedUrl = 'http://localhost:' + server.port + basePath + video.uuid + for (const suffix of [ '', '?param=1' ]) { + const oembedUrl = server.url + basePath + video.uuid + suffix - const res = await server.services.getOEmbed({ oembedUrl }) - const expectedHtml = '' - const expectedThumbnailUrl = 'http://localhost:' + server.port + video.previewPath + const res = await server.services.getOEmbed({ oembedUrl }) + const expectedHtml = '' + const expectedThumbnailUrl = 'http://localhost:' + server.port + video.previewPath - expect(res.body.html).to.equal(expectedHtml) - expect(res.body.title).to.equal(video.name) - expect(res.body.author_name).to.equal(server.store.channel.displayName) - expect(res.body.width).to.equal(560) - expect(res.body.height).to.equal(315) - expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl) - expect(res.body.thumbnail_width).to.equal(850) - expect(res.body.thumbnail_height).to.equal(480) + expect(res.body.html).to.equal(expectedHtml) + expect(res.body.title).to.equal(video.name) + expect(res.body.author_name).to.equal(server.store.channel.displayName) + expect(res.body.width).to.equal(560) + expect(res.body.height).to.equal(315) + expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl) + expect(res.body.thumbnail_width).to.equal(850) + expect(res.body.thumbnail_height).to.equal(480) + } } }) it('Should have a valid playlist oEmbed response', async function () { for (const basePath of [ '/videos/watch/playlist/', '/w/p/' ]) { - const oembedUrl = 'http://localhost:' + server.port + basePath + playlistUUID + for (const suffix of [ '', '?param=1' ]) { + const oembedUrl = server.url + basePath + playlistUUID + suffix - const res = await server.services.getOEmbed({ oembedUrl }) - const expectedHtml = '' + const res = await server.services.getOEmbed({ oembedUrl }) + const expectedHtml = '' - expect(res.body.html).to.equal(expectedHtml) - expect(res.body.title).to.equal('The Life and Times of Scrooge McDuck') - expect(res.body.author_name).to.equal(server.store.channel.displayName) - expect(res.body.width).to.equal(560) - expect(res.body.height).to.equal(315) - expect(res.body.thumbnail_url).exist - expect(res.body.thumbnail_width).to.equal(280) - expect(res.body.thumbnail_height).to.equal(157) + expect(res.body.html).to.equal(expectedHtml) + expect(res.body.title).to.equal('The Life and Times of Scrooge McDuck') + expect(res.body.author_name).to.equal(server.store.channel.displayName) + expect(res.body.width).to.equal(560) + expect(res.body.height).to.equal(315) + expect(res.body.thumbnail_url).exist + expect(res.body.thumbnail_width).to.equal(280) + expect(res.body.thumbnail_height).to.equal(157) + } } }) From 78ff11fc25a0db3d7adfa5b06446b1f9f5ef4a77 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 8 Oct 2021 14:51:03 +0200 Subject: [PATCH 07/13] Fix client build --- client/src/root-helpers/peertube-web-storage.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/src/root-helpers/peertube-web-storage.ts b/client/src/root-helpers/peertube-web-storage.ts index 0bbe2c9fc..3622cdc44 100644 --- a/client/src/root-helpers/peertube-web-storage.ts +++ b/client/src/root-helpers/peertube-web-storage.ts @@ -6,7 +6,8 @@ function proxify (instance: MemoryStorage) { return new Proxy(instance, { set: function (obj, prop: string | symbol, value) { if (Object.prototype.hasOwnProperty.call(MemoryStorage, prop)) { - instance[prop] = value + // FIXME: remove cast on typescript upgrade + instance[prop as any] = value } else { instance.setItem(prop, value) } @@ -14,8 +15,10 @@ function proxify (instance: MemoryStorage) { return true }, get: function (target, name: string | symbol | number) { - if (typeof instance[name] === 'function') { - return instance[name] + // FIXME: remove cast on typescript upgrade + if (typeof instance[name as any] === 'function') { + // FIXME: remove cast on typescript upgrade + return instance[name as any] } else if (valuesMap.has(name)) { return instance.getItem(name) } @@ -24,7 +27,7 @@ function proxify (instance: MemoryStorage) { } class MemoryStorage implements Storage { - [key: string | symbol]: any + [key: string]: any getItem (key: any) { const stringKey = String(key) From f82416cc58f6c1d0496935e815f3fcb2fdda88ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 8 Oct 2021 15:06:45 +0200 Subject: [PATCH 08/13] More robust youtube-dl thumbnail import --- server/controllers/api/videos/import.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 5f90e4308..4265f3217 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts @@ -158,7 +158,11 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response) // Process video thumbnail from url if processing from request.files failed if (!thumbnailModel && youtubeDLInfo.thumbnailUrl) { - thumbnailModel = await processThumbnailFromUrl(youtubeDLInfo.thumbnailUrl, video) + try { + thumbnailModel = await processThumbnailFromUrl(youtubeDLInfo.thumbnailUrl, video) + } catch (err) { + logger.warn('Cannot process thumbnail %s from youtubedl.', youtubeDLInfo.thumbnailUrl, { err }) + } } // Process video preview from request.files @@ -166,7 +170,11 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response) // Process video preview from url if processing from request.files failed if (!previewModel && youtubeDLInfo.thumbnailUrl) { - previewModel = await processPreviewFromUrl(youtubeDLInfo.thumbnailUrl, video) + try { + previewModel = await processPreviewFromUrl(youtubeDLInfo.thumbnailUrl, video) + } catch (err) { + logger.warn('Cannot process preview %s from youtubedl.', youtubeDLInfo.thumbnailUrl, { err }) + } } const videoImport = await insertIntoDB({ From efa3fef23ecf4e1c5289f8715de184c272ea49f7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 8 Oct 2021 15:34:07 +0200 Subject: [PATCH 09/13] Fix notification on create transcoding job --- server/lib/video-state.ts | 6 +++--- server/models/video/video.ts | 4 ++-- server/tests/cli/create-transcoding-job.ts | 16 +++++++++++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/server/lib/video-state.ts b/server/lib/video-state.ts index 0613d94bf..9352a67d1 100644 --- a/server/lib/video-state.ts +++ b/server/lib/video-state.ts @@ -70,13 +70,13 @@ async function moveToPublishedState (video: MVideoFullLight, isNewVideo: boolean logger.info('Publishing video %s.', video.uuid, { tags: [ video.uuid ] }) const previousState = video.state - await video.setNewState(VideoState.PUBLISHED, transaction) + await video.setNewState(VideoState.PUBLISHED, isNewVideo, transaction) // If the video was not published, we consider it is a new one for other instances // Live videos are always federated, so it's not a new video await federateVideoIfNeeded(video, isNewVideo, transaction) - Notifier.Instance.notifyOnNewVideoIfNeeded(video) + if (isNewVideo) Notifier.Instance.notifyOnNewVideoIfNeeded(video) if (previousState === VideoState.TO_TRANSCODE) { Notifier.Instance.notifyOnVideoPublishedAfterTranscoding(video) @@ -90,7 +90,7 @@ async function moveToExternalStorageState (video: MVideoFullLight, isNewVideo: b // We want to wait all transcoding jobs before moving the video on an external storage if (pendingTranscode !== 0) return - await video.setNewState(VideoState.TO_MOVE_TO_EXTERNAL_STORAGE, transaction) + await video.setNewState(VideoState.TO_MOVE_TO_EXTERNAL_STORAGE, isNewVideo, transaction) logger.info('Creating external storage move job for video %s.', video.uuid, { tags: [ video.uuid ] }) diff --git a/server/models/video/video.ts b/server/models/video/video.ts index e0c4dd2db..d2daf18ee 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -1766,12 +1766,12 @@ export class VideoModel extends Model>> { this.privacy === VideoPrivacy.INTERNAL } - async setNewState (newState: VideoState, transaction: Transaction) { + async setNewState (newState: VideoState, isNewVideo: boolean, transaction: Transaction) { if (this.state === newState) throw new Error('Cannot use same state ' + newState) this.state = newState - if (this.state === VideoState.PUBLISHED) { + if (this.state === VideoState.PUBLISHED && isNewVideo) { this.publishedAt = new Date() } diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts index 3fd624091..2b388ab0c 100644 --- a/server/tests/cli/create-transcoding-job.ts +++ b/server/tests/cli/create-transcoding-job.ts @@ -33,9 +33,10 @@ async function checkFilesInObjectStorage (files: VideoFile[], type: 'webtorrent' function runTests (objectStorage: boolean) { let servers: PeerTubeServer[] = [] const videosUUID: string[] = [] + const publishedAt: string[] = [] before(async function () { - this.timeout(60000) + this.timeout(120000) const config = objectStorage ? ObjectStorageCommand.getDefaultConfig() @@ -54,6 +55,11 @@ function runTests (objectStorage: boolean) { for (let i = 1; i <= 5; i++) { const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'video' + i } }) + await waitJobs(servers) + + const video = await servers[0].videos.get({ id: uuid }) + publishedAt.push(video.publishedAt as string) + if (i > 2) { videosUUID.push(uuid) } else { @@ -225,6 +231,14 @@ function runTests (objectStorage: boolean) { } }) + it('Should not have updated published at attributes', async function () { + for (const id of videosUUID) { + const video = await servers[0].videos.get({ id }) + + expect(publishedAt.some(p => video.publishedAt === p)).to.be.true + } + }) + after(async function () { await cleanupTests(servers) }) From b51e5b74019bcd67d9adafd48c0cd79affe84892 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 8 Oct 2021 15:59:05 +0200 Subject: [PATCH 10/13] Correctly disable infinite scroll for reuse --- client/src/app/core/routing/custom-reuse-strategy.ts | 12 +++++++----- .../angular/infinite-scroller.directive.ts | 3 ++- .../videos-list.component.html | 3 ++- .../videos-selection.component.html | 3 ++- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/client/src/app/core/routing/custom-reuse-strategy.ts b/client/src/app/core/routing/custom-reuse-strategy.ts index 3000093a8..1498e221f 100644 --- a/client/src/app/core/routing/custom-reuse-strategy.ts +++ b/client/src/app/core/routing/custom-reuse-strategy.ts @@ -1,7 +1,7 @@ -import { Injectable } from '@angular/core' +import { ComponentRef, Injectable } from '@angular/core' import { ActivatedRouteSnapshot, DetachedRouteHandle, RouteReuseStrategy } from '@angular/router' -import { RouterSetting } from './' -import { PeerTubeRouterService } from './peertube-router.service' +import { DisableForReuseHook } from './disable-for-reuse-hook' +import { PeerTubeRouterService, RouterSetting } from './peertube-router.service' @Injectable() export class CustomReuseStrategy implements RouteReuseStrategy { @@ -22,9 +22,11 @@ export class CustomReuseStrategy implements RouteReuseStrategy { const key = this.generateKey(route) this.recentlyUsed = key - console.log('Storing component %s to reuse later.', key); + console.log('Storing component %s to reuse later.', key) - (handle as any).componentRef.instance.disableForReuse() + const componentRef = (handle as any).componentRef as ComponentRef + componentRef.instance.disableForReuse() + componentRef.changeDetectorRef.detectChanges() this.storedRouteHandles.set(key, handle) diff --git a/client/src/app/shared/shared-main/angular/infinite-scroller.directive.ts b/client/src/app/shared/shared-main/angular/infinite-scroller.directive.ts index bebc6efa7..c247cfde2 100644 --- a/client/src/app/shared/shared-main/angular/infinite-scroller.directive.ts +++ b/client/src/app/shared/shared-main/angular/infinite-scroller.directive.ts @@ -13,6 +13,7 @@ export class InfiniteScrollerDirective implements OnInit, OnDestroy, AfterViewCh // Add angular state in query params to reuse the routed component @Input() setAngularState: boolean + @Input() parentDisabled = false @Output() nearOfBottom = new EventEmitter() @@ -74,7 +75,7 @@ export class InfiniteScrollerDirective implements OnInit, OnDestroy, AfterViewCh filter(({ current, maximumScroll }) => (current / maximumScroll) > this.decimalLimit) ) .subscribe(() => { - if (this.setAngularState) this.setScrollRouteParams() + if (this.setAngularState && !this.parentDisabled) this.setScrollRouteParams() this.nearOfBottom.emit() }) diff --git a/client/src/app/shared/shared-video-miniature/videos-list.component.html b/client/src/app/shared/shared-video-miniature/videos-list.component.html index 67933f177..2b554517f 100644 --- a/client/src/app/shared/shared-video-miniature/videos-list.component.html +++ b/client/src/app/shared/shared-video-miniature/videos-list.component.html @@ -40,7 +40,8 @@
No results.
diff --git a/client/src/app/shared/shared-video-miniature/videos-selection.component.html b/client/src/app/shared/shared-video-miniature/videos-selection.component.html index f2af874dd..6ea2661e4 100644 --- a/client/src/app/shared/shared-video-miniature/videos-selection.component.html +++ b/client/src/app/shared/shared-video-miniature/videos-selection.component.html @@ -2,7 +2,8 @@
From d8fb3a2f0de0a7600d5fb130b219aff28fd08830 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 8 Oct 2021 16:00:32 +0200 Subject: [PATCH 11/13] Increase live tests timeout --- server/tests/api/live/live.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index ba952aff5..5cac3bc4e 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts @@ -439,7 +439,7 @@ describe('Test live', function () { }) it('Should enable transcoding without additional resolutions', async function () { - this.timeout(60000) + this.timeout(120000) liveVideoId = await createLiveWrapper(false) @@ -453,7 +453,7 @@ describe('Test live', function () { }) it('Should enable transcoding with some resolutions', async function () { - this.timeout(60000) + this.timeout(120000) const resolutions = [ 240, 480 ] await updateConf(resolutions) From 979139d2d2fb21a92e023abdbb41b3a04d235042 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 11 Oct 2021 09:09:50 +0200 Subject: [PATCH 12/13] Bump changelog --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83a1f2549..fec8926f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## v3.4.1 + +### Bug fixes + + * Fix broken PeerTube when cookies are disabled or if the embed iframe does not have appropriate options + * Fix search by channel's handle with an handle containing the local host + * Don't display autoblock message in upload page it is not enabled by the admin + * Don't index `/about/peertube` page + * Correctly handle OEmbed with an URL containing query parameters + * More robust youtube-dl thumbnail import + * Don't send a new video notification when using create transcoding CLI script + + ## v3.4.0 ### IMPORTANT NOTES From 3edbafb6377cfb65bca3964d46fa27bc9f813300 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 11 Oct 2021 09:23:55 +0200 Subject: [PATCH 13/13] Bumped to version v3.4.1 --- client/package.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/package.json b/client/package.json index fed8f58b2..ffe7df4cd 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "peertube-client", - "version": "3.4.0", + "version": "3.4.1", "private": true, "license": "AGPL-3.0", "author": { diff --git a/package.json b/package.json index c46382286..ef22e2961 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "peertube", "description": "PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.", - "version": "3.4.0", + "version": "3.4.1", "private": true, "licence": "AGPL-3.0", "engines": {