ActivityPub-federated video streaming platform using P2P directly in your web browser
Remove twitter whitelisted option
Chocobozzz10e78bb778e6
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.htmlindex 1f3ba283fe..d63f13c339 100644--- a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html+++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html@@ -671,10 +671,10 @@<div class="pt-two-cols mt-4"> <!-- Twitter grid --><div class="title-col">- <h2 i18n>TWITTER</h2>+ <h2 i18n>TWITTER/X</h2>+<div i18n class="inner-form-description">- Provide the Twitter account representing your instance to improve link previews.- If you don't have a Twitter account, just leave the default value.+ Extra configuration required by Twitter/X. All other social media (Facebook, Mastodon, etc.) are supported out of the box.</div></div>@@ -684,7 +684,13 @@<ng-container formGroupName="twitter"><div class="form-group">- <label for="servicesTwitterUsername" i18n>Your Twitter username</label>+ <label for="servicesTwitterUsername" i18n>Your Twitter/X username</label>++ <div class="label-small-info">+ <p class="mb-0">Indicates the Twitter/X account for the website or platform where the content was published.</p>++ <p>This is just an extra information injected in PeerTube HTML that is required by Twitter/X. If you don't have a Twitter/X account, just leave the default value.</p>+ </div><inputtype="text" id="servicesTwitterUsername" class="form-control"@@ -694,29 +700,6 @@<div *ngIf="formErrors.services.twitter.username" class="form-error" role="alert">{{ formErrors.services.twitter.username }}</div></div>- <div class="form-group">- <my-peertube-checkbox inputName="servicesTwitterWhitelisted" formControlName="whitelisted">- <ng-template ptTemplate="label">- <ng-container i18n>Instance allowed by Twitter/X</ng-container>- </ng-template>-- <ng-template ptTemplate="help">- <ng-container i18n>- <p class="mb-2">- If your instance is explicitly allowed by Twitter/X, a video player will be embedded in the Twitter feed on PeerTube video share.<br />- If the instance is not, we use an image link card that will redirect to your PeerTube instance.- </p>-- <p>- Check this checkbox, save the configuration and test with a video URL of your instance (https://example.com/w/blabla) on- <a class="link-orange" target='_blank' rel='noopener noreferrer' href='https://cards-dev.twitter.com/validator'>https://cards-dev.twitter.com/validator</a>- to see if you instance is allowed.- </p>- </ng-container>- </ng-template>- </my-peertube-checkbox>- </div>-</ng-container></ng-container>diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.tsindex 452c259c05..08fb9e29e5 100644--- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts+++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts@@ -131,8 +131,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {},services: {twitter: {- username: SERVICES_TWITTER_USERNAME_VALIDATOR,- whitelisted: null+ username: SERVICES_TWITTER_USERNAME_VALIDATOR}},client: {diff --git a/config/default.yaml b/config/default.yamlindex 7787dc1d63..4bd0c9a7a2 100644--- a/config/default.yaml+++ b/config/default.yaml@@ -841,13 +841,12 @@ instance:Expires: 2025-12-31T11:00:00.000Z'services:- # Cards configuration to format video in Twitter+ # Cards configuration to format video in Twitter/X+ # All other social media (Facebook, Mastodon, etc.) are supported out of the boxtwitter:- username: '@Chocobozzz' # Indicates the Twitter account for the website or platform on which the content was published- # If true, a video player will be embedded in the Twitter feed on PeerTube video share- # If false, we use an image link card that will redirect on your PeerTube instance- # Change it to `true`, and then test on https://cards-dev.twitter.com/validator to see if you are whitelisted- whitelisted: false+ # Indicates the Twitter account for the website or platform where the content was published+ # This is just an information injected in HTML that is required by Twitter/X+ username: '@Chocobozzz'followers:instance:diff --git a/config/production.yaml.example b/config/production.yaml.exampleindex 05577c2024..b645c5fda2 100644--- a/config/production.yaml.example+++ b/config/production.yaml.example@@ -851,13 +851,12 @@ instance:Expires: 2025-12-31T11:00:00.000Z'services:- # Cards configuration to format video in Twitter+ # Cards configuration to format video in Twitter/X+ # All other social media (Facebook, Mastodon, etc.) are supported out of the boxtwitter:- username: '@Chocobozzz' # Indicates the Twitter account for the website or platform on which the content was published- # If true, a video player will be embedded in the Twitter feed on PeerTube video share- # If false, we use an image link card that will redirect on your PeerTube instance- # Change it to `true`, and then test on https://cards-dev.twitter.com/validator to see if you are whitelisted- whitelisted: false+ # Indicates the Twitter/X account for the website or platform where the content was published+ # This is just an information injected in HTML that is required by Twitter/X+ username: '@Chocobozzz'followers:instance:diff --git a/packages/models/src/server/custom-config.model.ts b/packages/models/src/server/custom-config.model.tsindex 3f52fb31a0..9b77147b97 100644--- a/packages/models/src/server/custom-config.model.ts+++ b/packages/models/src/server/custom-config.model.ts@@ -48,7 +48,6 @@ export interface CustomConfig {services: {twitter: {username: string- whitelisted: boolean}}diff --git a/packages/server-commands/src/server/config-command.ts b/packages/server-commands/src/server/config-command.tsindex cd3fc6f446..64be64bf5b 100644--- a/packages/server-commands/src/server/config-command.ts+++ b/packages/server-commands/src/server/config-command.ts@@ -503,8 +503,7 @@ export class ConfigCommand extends AbstractCommand {},services: {twitter: {- username: '@MySuperUsername',- whitelisted: true+ username: '@MySuperUsername'}},client: {diff --git a/packages/tests/src/api/check-params/config.ts b/packages/tests/src/api/check-params/config.tsindex 4e093ed263..3eef13e6f9 100644--- a/packages/tests/src/api/check-params/config.ts+++ b/packages/tests/src/api/check-params/config.ts@@ -52,8 +52,7 @@ describe('Test config API validators', function () {},services: {twitter: {- username: '@MySuperUsername',- whitelisted: true+ username: '@MySuperUsername'}},client: {diff --git a/packages/tests/src/api/server/config.ts b/packages/tests/src/api/server/config.tsindex 85d40e232e..e503541a8d 100644--- a/packages/tests/src/api/server/config.ts+++ b/packages/tests/src/api/server/config.ts@@ -42,7 +42,6 @@ function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) {expect(data.instance.customizations.javascript).to.be.emptyexpect(data.services.twitter.username).to.equal('@Chocobozzz')- expect(data.services.twitter.whitelisted).to.be.falseexpect(data.client.videos.miniature.preferAuthorDisplayName).to.be.falseexpect(data.client.menu.login.redirectOnSingleExternalAuth).to.be.false@@ -161,7 +160,6 @@ function checkUpdatedConfig (data: CustomConfig) {expect(data.instance.customizations.css).to.equal('body { background-color: red; }')expect(data.services.twitter.username).to.equal('@Kuja')- expect(data.services.twitter.whitelisted).to.be.trueexpect(data.client.videos.miniature.preferAuthorDisplayName).to.be.trueexpect(data.client.menu.login.redirectOnSingleExternalAuth).to.be.true@@ -291,8 +289,7 @@ const newCustomConfig: CustomConfig = {},services: {twitter: {- username: '@Kuja',- whitelisted: true+ username: '@Kuja'}},client: {diff --git a/packages/tests/src/client/og-twitter-tags.ts b/packages/tests/src/client/og-twitter-tags.tsindex d5480087d9..0244dce0bb 100644--- a/packages/tests/src/client/og-twitter-tags.ts+++ b/packages/tests/src/client/og-twitter-tags.ts@@ -120,148 +120,73 @@ describe('Test Open Graph and Twitter cards HTML tags', function () {describe('Twitter card', async function () {- describe('Not whitelisted', function () {-- async function accountPageTest (path: string) {- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })- const text = res.text-- expect(text).to.contain('<meta property="twitter:card" content="summary" />')- expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')- expect(text).to.contain(`<meta property="twitter:title" content="${account.name}" />`)- expect(text).to.contain(`<meta property="twitter:description" content="${account.description}" />`)+ before(async function () {+ const config = await servers[0].config.getCustomConfig()+ config.services.twitter = {+ username: '@Kuja'}- async function channelPageTest (path: string) {- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })- const text = res.text-- expect(text).to.contain('<meta property="twitter:card" content="summary" />')- expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')- expect(text).to.contain(`<meta property="twitter:title" content="${servers[0].store.channel.displayName}" />`)- expect(text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`)- }-- async function watchVideoPageTest (path: string) {- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })- const text = res.text-- expect(text).to.contain('<meta property="twitter:card" content="summary_large_image" />')- expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')- expect(text).to.contain(`<meta property="twitter:title" content="${videoName}" />`)- expect(text).to.contain(`<meta property="twitter:description" content="${videoDescriptionPlainText}" />`)- }-- async function watchPlaylistPageTest (path: string) {- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })- const text = res.text-- expect(text).to.contain('<meta property="twitter:card" content="summary" />')- expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')- expect(text).to.contain(`<meta property="twitter:title" content="${playlistName}" />`)- expect(text).to.contain(`<meta property="twitter:description" content="${playlistDescription}" />`)- }-- it('Should have valid twitter card on the watch video page', async function () {- for (const path of getWatchVideoBasePaths()) {- for (const id of videoIds) {- await watchVideoPageTest(path + id)- }- }- })-- it('Should have valid twitter card on the watch playlist page', async function () {- for (const path of getWatchPlaylistBasePaths()) {- for (const id of playlistIds) {- await watchPlaylistPageTest(path + id)- }- }- })-- it('Should have valid twitter card on the account page', async function () {- await accountPageTest('/accounts/' + account.name)- await accountPageTest('/a/' + account.name)- await accountPageTest('/@' + account.name)- })-- it('Should have valid twitter card on the channel page', async function () {- await channelPageTest('/video-channels/' + servers[0].store.channel.name)- await channelPageTest('/c/' + servers[0].store.channel.name)- await channelPageTest('/@' + servers[0].store.channel.name)- })+ await servers[0].config.updateCustomConfig({ newCustomConfig: config })})- describe('Whitelisted', function () {+ async function accountPageTest (path: string) {+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })+ const text = res.text- before(async function () {- const config = await servers[0].config.getCustomConfig()- config.services.twitter = {- username: '@Kuja',- whitelisted: true- }+ expect(text).to.contain('<meta property="twitter:card" content="summary" />')+ expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')+ }- await servers[0].config.updateCustomConfig({ newCustomConfig: config })- })+ async function channelPageTest (path: string) {+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })+ const text = res.text- async function accountPageTest (path: string) {- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })- const text = res.text+ expect(text).to.contain('<meta property="twitter:card" content="summary" />')+ expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')+ }- expect(text).to.contain('<meta property="twitter:card" content="summary" />')- expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')- }+ async function watchVideoPageTest (path: string) {+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })+ const text = res.text- async function channelPageTest (path: string) {- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })- const text = res.text+ expect(text).to.contain('<meta property="twitter:card" content="player" />')+ expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')+ }- expect(text).to.contain('<meta property="twitter:card" content="summary" />')- expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')- }+ async function watchPlaylistPageTest (path: string) {+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })+ const text = res.text- async function watchVideoPageTest (path: string) {- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })- const text = res.text+ expect(text).to.contain('<meta property="twitter:card" content="player" />')+ expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')+ }- expect(text).to.contain('<meta property="twitter:card" content="player" />')- expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')+ it('Should have valid twitter card on the watch video page', async function () {+ for (const path of getWatchVideoBasePaths()) {+ for (const id of videoIds) {+ await watchVideoPageTest(path + id)+ }}+ })- async function watchPlaylistPageTest (path: string) {- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })- const text = res.text-- expect(text).to.contain('<meta property="twitter:card" content="player" />')- expect(text).to.contain('<meta property="twitter:site" content="@Kuja" />')+ it('Should have valid twitter card on the watch playlist page', async function () {+ for (const path of getWatchPlaylistBasePaths()) {+ for (const id of playlistIds) {+ await watchPlaylistPageTest(path + id)+ }}+ })- it('Should have valid twitter card on the watch video page', async function () {- for (const path of getWatchVideoBasePaths()) {- for (const id of videoIds) {- await watchVideoPageTest(path + id)- }- }- })+ it('Should have valid twitter card on the account page', async function () {+ await accountPageTest('/accounts/' + account.name)+ await accountPageTest('/a/' + account.name)+ await accountPageTest('/@' + account.name)+ })- it('Should have valid twitter card on the watch playlist page', async function () {- for (const path of getWatchPlaylistBasePaths()) {- for (const id of playlistIds) {- await watchPlaylistPageTest(path + id)- }- }- })-- it('Should have valid twitter card on the account page', async function () {- await accountPageTest('/accounts/' + account.name)- await accountPageTest('/a/' + account.name)- await accountPageTest('/@' + account.name)- })-- it('Should have valid twitter card on the channel page', async function () {- await channelPageTest('/video-channels/' + servers[0].store.channel.name)- await channelPageTest('/c/' + servers[0].store.channel.name)- await channelPageTest('/@' + servers[0].store.channel.name)- })+ it('Should have valid twitter card on the channel page', async function () {+ await channelPageTest('/video-channels/' + servers[0].store.channel.name)+ await channelPageTest('/c/' + servers[0].store.channel.name)+ await channelPageTest('/@' + servers[0].store.channel.name)})})diff --git a/server/core/controllers/api/config.ts b/server/core/controllers/api/config.tsindex a04524714f..bbaa9f69e5 100644--- a/server/core/controllers/api/config.ts+++ b/server/core/controllers/api/config.ts@@ -263,8 +263,7 @@ function customConfig (): CustomConfig {},services: {twitter: {- username: CONFIG.SERVICES.TWITTER.USERNAME,- whitelisted: CONFIG.SERVICES.TWITTER.WHITELISTED+ username: CONFIG.SERVICES.TWITTER.USERNAME}},client: {diff --git a/server/core/helpers/audit-logger.ts b/server/core/helpers/audit-logger.tsindex f5fbb9d847..5958acbf5c 100644--- a/server/core/helpers/audit-logger.ts+++ b/server/core/helpers/audit-logger.ts@@ -243,7 +243,6 @@ const customConfigKeysToKeep = new Set(['instance-customizations-javascript','instance-customizations-css','services-twitter-username',- 'services-twitter-whitelisted','cache-previews-size','cache-captions-size','signup-enabled',diff --git a/server/core/initializers/checker-before-init.ts b/server/core/initializers/checker-before-init.tsindex d7415958f6..a75a4ecabd 100644--- a/server/core/initializers/checker-before-init.ts+++ b/server/core/initializers/checker-before-init.ts@@ -51,7 +51,7 @@ function checkMissedConfig () {'defaults.publish.download_enabled', 'defaults.publish.comments_enabled', 'defaults.publish.privacy', 'defaults.publish.licence','instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route','instance.is_nsfw', 'instance.default_nsfw_policy', 'instance.robots', 'instance.securitytxt',- 'services.twitter.username', 'services.twitter.whitelisted',+ 'services.twitter.username','followers.instance.enabled', 'followers.instance.manual_approval','tracker.enabled', 'tracker.private', 'tracker.reject_too_many_announces','history.videos.max_age', 'views.videos.remote.max_age', 'views.videos.local_buffer_update_interval', 'views.videos.ip_view_expiration',diff --git a/server/core/initializers/config.ts b/server/core/initializers/config.tsindex 4da75126d7..51845b4a0a 100644--- a/server/core/initializers/config.ts+++ b/server/core/initializers/config.ts@@ -596,8 +596,7 @@ const CONFIG = {},SERVICES: {TWITTER: {- get USERNAME () { return config.get<string>('services.twitter.username') },- get WHITELISTED () { return config.get<boolean>('services.twitter.whitelisted') }+ get USERNAME () { return config.get<string>('services.twitter.username') }}},FOLLOWERS: {diff --git a/server/core/lib/html/shared/playlist-html.ts b/server/core/lib/html/shared/playlist-html.tsindex 17d9e180fa..e5df277ea2 100644--- a/server/core/lib/html/shared/playlist-html.ts+++ b/server/core/lib/html/shared/playlist-html.ts@@ -87,12 +87,9 @@ export class PlaylistHtml {const list = { numberOfItems: playlist.get('videosLength') as number }const schemaType = 'ItemList'- let twitterCard: 'player' | 'summary'- if (addTwitterCard) {- twitterCard = CONFIG.SERVICES.TWITTER.WHITELISTED- ? 'player'- : 'summary'- }+ const twitterCard = addTwitterCard+ ? 'player'+ : undefinedconst ogType = addOG? 'video' as 'video'diff --git a/server/core/lib/html/shared/video-html.ts b/server/core/lib/html/shared/video-html.tsindex 1649228e28..ccffc683d1 100644--- a/server/core/lib/html/shared/video-html.ts+++ b/server/core/lib/html/shared/video-html.ts@@ -1,6 +1,7 @@import { escapeHTML } from '@peertube/peertube-core-utils'import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models'import { toCompleteUUID } from '@server/helpers/custom-validators/misc.js'+import { Memoize } from '@server/helpers/memoize.js'import express from 'express'import validator from 'validator'import { CONFIG } from '../../../initializers/config.js'@@ -9,10 +10,9 @@ import { VideoModel } from '../../../models/video/video.js'import { MVideo, MVideoThumbnailBlacklist } from '../../../types/models/index.js'import { getActivityStreamDuration } from '../../activitypub/activity.js'import { isVideoInPrivateDirectory } from '../../video-privacy.js'-import { Memoize } from '@server/helpers/memoize.js'-import { TagsHtml } from './tags-html.js'-import { PageHtml } from './page-html.js'import { CommonEmbedHtml } from './common-embed-html.js'+import { PageHtml } from './page-html.js'+import { TagsHtml } from './tags-html.js'export class VideoHtml {@@ -99,12 +99,9 @@ export class VideoHtml {? 'video' as 'video': undefined- let twitterCard: 'player' | 'summary_large_image'- if (addTwitterCard) {- twitterCard = CONFIG.SERVICES.TWITTER.WHITELISTED- ? 'player'- : 'summary_large_image'- }+ const twitterCard = addTwitterCard+ ? 'player'+ : undefinedconst schemaType = 'VideoObject'diff --git a/server/core/middlewares/validators/config.ts b/server/core/middlewares/validators/config.tsindex b9477b75e4..f3bab58516 100644--- a/server/core/middlewares/validators/config.ts+++ b/server/core/middlewares/validators/config.ts@@ -19,7 +19,6 @@ const customConfigUpdateValidator = [body('instance.customizations.javascript').exists(),body('services.twitter.username').exists(),- body('services.twitter.whitelisted').isBoolean(),body('cache.previews.size').isInt(),body('cache.captions.size').isInt(),diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yamlindex 983b65c13a..e6884fee91 100644--- a/support/doc/api/openapi.yaml+++ b/support/doc/api/openapi.yaml@@ -8743,8 +8743,6 @@ components:properties:username:type: string- whitelisted:- type: booleancache:type: objectproperties: