ActivityPub-federated video streaming platform using P2P directly in your web browser
Use 1500x1500px images for feeds
Chocobozzz7f5256e57590
diff --git a/client/src/assets/images/icons/icon-1500x1500.png b/client/src/assets/images/icons/icon-1500x1500.pngnew file mode 100644index 0000000000..ce006f2c90Binary files /dev/null and b/client/src/assets/images/icons/icon-1500x1500.png differdiff --git a/packages/tests/src/feeds/feeds.ts b/packages/tests/src/feeds/feeds.tsindex 38bbaacc04..51aa197509 100644--- a/packages/tests/src/feeds/feeds.ts+++ b/packages/tests/src/feeds/feeds.ts@@ -16,7 +16,7 @@ import {stopFfmpeg,waitJobs} from '@peertube/peertube-server-commands'-import { expectStartWith } from '@tests/shared/checks.js'+import { expectStartWith, testImageSize } from '@tests/shared/checks.js'import * as chai from 'chai'import chaiJSONSChema from 'chai-json-schema'import chaiXML from 'chai-xml'@@ -352,7 +352,11 @@ describe('Test syndication feeds', () => {expect(channel['itunes:author']).to.equal('PeerTube')expect(channel['itunes:image']['@_href']).to.exist- await makeRawRequest({ url: channel['itunes:image']['@_href'], expectedStatus: HttpStatusCode.OK_200 })++ {+ const { body } = await makeRawRequest({ url: channel['itunes:image']['@_href'], expectedStatus: HttpStatusCode.OK_200 })+ await testImageSize({ buffer: body, width: 1500, height: 1500 })+ }const item = xmlDoc.rss.channel.itemdiff --git a/packages/tests/src/shared/checks.ts b/packages/tests/src/shared/checks.tsindex 62ee0acaed..30c38f90d8 100644--- a/packages/tests/src/shared/checks.ts+++ b/packages/tests/src/shared/checks.ts@@ -9,40 +9,40 @@ import { readFile, writeFile } from 'fs/promises'import { join, parse } from 'path'// Default interval -> 5 minutes-function dateIsValid (dateString: string | Date, interval = 300000) {+export function dateIsValid (dateString: string | Date, interval = 300000) {const dateToCheck = new Date(dateString)const now = new Date()return Math.abs(now.getTime() - dateToCheck.getTime()) <= interval}-function expectStartWith (str: string, start: string) {+export function expectStartWith (str: string, start: string) {expect(str.startsWith(start), `${str} does not start with ${start}`).to.be.true}-function expectNotStartWith (str: string, start: string) {+export function expectNotStartWith (str: string, start: string) {expect(str.startsWith(start), `${str} does not start with ${start}`).to.be.false}-function expectEndWith (str: string, end: string) {+export function expectEndWith (str: string, end: string) {expect(str.endsWith(end), `${str} does not end with ${end}`).to.be.true}// ----------------------------------------------------------------------------async function expectLogDoesNotContain (server: PeerTubeServer, str: string) {+export async function expectLogDoesNotContain (server: PeerTubeServer, str: string) {const content = await server.servers.getLogContent()expect(content.toString()).to.not.contain(str)}-async function expectLogContain (server: PeerTubeServer, str: string) {+export async function expectLogContain (server: PeerTubeServer, str: string) {const content = await server.servers.getLogContent()expect(content.toString()).to.contain(str)}-async function testAvatarSize (options: {+export async function testAvatarSize (options: {url: stringimageName: stringavatar: {@@ -79,7 +79,7 @@ async function testAvatarSize (options: {}}-async function testImageGeneratedByFFmpeg (options: {+export async function testImageGeneratedByFFmpeg (options: {url: stringname: string}) {@@ -94,7 +94,7 @@ async function testImageGeneratedByFFmpeg (options: {return testImage(options)}-async function testImage (options: {+export async function testImage (options: {name: stringurl: string}) {@@ -135,15 +135,30 @@ async function testImage (options: {}}-async function testFileExistsOnFSOrNot (server: PeerTubeServer, directory: string, filePath: string, exist: boolean) {+export async function testFileExistsOnFSOrNot (server: PeerTubeServer, directory: string, filePath: string, exist: boolean) {const base = server.servers.buildDirectory(directory)expect(await pathExists(join(base, filePath))).to.equal(exist)}+export async function testImageSize (options: {+ buffer: Buffer+ width: number+ height: number+}) {+ const { buffer, width, height } = options++ const sharp = (await import('sharp')).default+ const img = sharp(buffer)+ const metadata = await img.metadata()++ expect(metadata.width).to.equal(width)+ expect(metadata.height).to.equal(height)+}+// ----------------------------------------------------------------------------function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {+export function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {return makeGetRequest({url,path,@@ -153,7 +168,7 @@ function checkBadStartPagination (url: string, path: string, token?: string, que})}-async function checkBadCountPagination (url: string, path: string, token?: string, query = {}) {+export async function checkBadCountPagination (url: string, path: string, token?: string, query = {}) {await makeGetRequest({url,path,@@ -171,7 +186,7 @@ async function checkBadCountPagination (url: string, path: string, token?: strin})}-function checkBadSort (url: string, path: string, token?: string, query = {}) {+export function checkBadSort (url: string, path: string, token?: string, query = {}) {return makeGetRequest({url,path,@@ -183,7 +198,7 @@ function checkBadSort (url: string, path: string, token?: string, query = {}) {// ----------------------------------------------------------------------------async function checkVideoDuration (server: PeerTubeServer, videoUUID: string, duration: number) {+export async function checkVideoDuration (server: PeerTubeServer, videoUUID: string, duration: number) {const video = await server.videos.get({ id: videoUUID })expect(video.duration).to.be.approximately(duration, 1)@@ -196,20 +211,3 @@ async function checkVideoDuration (server: PeerTubeServer, videoUUID: string, du}}}--export {- checkBadCountPagination,- checkBadSort,- checkBadStartPagination,- checkVideoDuration,- dateIsValid,- expectEndWith,- expectLogContain,- expectLogDoesNotContain,- expectNotStartWith,- expectStartWith,- testAvatarSize,- testFileExistsOnFSOrNot,- testImage,- testImageGeneratedByFFmpeg-}diff --git a/server/core/controllers/feeds/shared/common-feed-utils.ts b/server/core/controllers/feeds/shared/common-feed-utils.tsindex 4c9b2baecc..1ef927fecc 100644--- a/server/core/controllers/feeds/shared/common-feed-utils.ts+++ b/server/core/controllers/feeds/shared/common-feed-utils.ts@@ -5,10 +5,11 @@ import { ActorImageType } from '@peertube/peertube-models'import { mdToPlainText } from '@server/helpers/markdown.js'import { CONFIG } from '@server/initializers/config.js'import { WEBSERVER } from '@server/initializers/constants.js'+import { regenerateActorImageFiles } from '@server/lib/local-actor.js'import { ServerConfigManager } from '@server/lib/server-config-manager.js'import { getServerActor } from '@server/models/application/application.js'import { UserModel } from '@server/models/user/user.js'-import { MAccountDefault, MChannelBannerAccountDefault, MUser, MVideoFullLight } from '@server/types/models/index.js'+import { MAccountDefault, MChannelBannerAccountDefault, MChannelDefault, MUser, MVideoFullLight } from '@server/types/models/index.js'import express from 'express'export async function initFeed (parameters: {@@ -117,7 +118,7 @@ export async function buildFeedMetadata (options: {}) {const { video, videoChannel, account } = options- let imageUrl = ServerConfigManager.Instance.getLogoUrl(await getServerActor(), 512)+ let imageUrl = ServerConfigManager.Instance.getLogoUrl(await getServerActor(), 1500)let ownerImageUrl: stringlet name: stringlet description: string@@ -133,7 +134,7 @@ export async function buildFeedMetadata (options: {link = ownerLinkif (videoChannel.Actor.hasImage(ActorImageType.AVATAR)) {- imageUrl = WEBSERVER.URL + videoChannel.Actor.getMaxQualityImage(ActorImageType.AVATAR).getStaticPath()+ imageUrl = await getOrGenerateImageUrl(videoChannel)ownerImageUrl = imageUrl}@@ -145,7 +146,7 @@ export async function buildFeedMetadata (options: {link = ownerLinkif (account.Actor.hasImage(ActorImageType.AVATAR)) {- imageUrl = WEBSERVER.URL + account.Actor.getMaxQualityImage(ActorImageType.AVATAR).getStaticPath()+ imageUrl = await getOrGenerateImageUrl(account)ownerImageUrl = imageUrl}@@ -168,3 +169,20 @@ export async function buildFeedMetadata (options: {return { name, description, imageUrl, ownerImageUrl, email, link, ownerLink }}++// ---------------------------------------------------------------------------+// Private+// ---------------------------------------------------------------------------++async function getOrGenerateImageUrl (accountOrChannel: MChannelDefault | MAccountDefault) {+ let image = accountOrChannel.Actor.getMaxQualityImage(ActorImageType.AVATAR)+ if (!image) throw new Error('No avatar image found for the account or channel')++ if (accountOrChannel.Actor.isLocal() && image.width < 1500) {+ await regenerateActorImageFiles({ accountOrChannel, type: ActorImageType.AVATAR })+ }++ image = accountOrChannel.Actor.getMaxQualityImage(ActorImageType.AVATAR)++ return image.getLocalFileUrl()+}diff --git a/server/core/lib/local-actor.ts b/server/core/lib/local-actor.tsindex f4ce471768..194080df9c 100644--- a/server/core/lib/local-actor.ts+++ b/server/core/lib/local-actor.ts@@ -92,6 +92,29 @@ export async function deleteLocalActorImageFile (accountOrChannel: MAccountDefau})}+export async function regenerateActorImageFiles (options: {+ accountOrChannel: MAccountDefault | MChannelDefault+ type: ActorImageType_Type+}) {+ const { accountOrChannel, type } = options++ if (accountOrChannel.Actor.isLocal() !== true) {+ throw new Error('Cannot regenerate actor image files for a remote actor')+ }++ const image = accountOrChannel.Actor.getMaxQualityImage(type)+ if (!image) return++ const physicalFilePath = image.getFSPath()++ return updateLocalActorImageFiles({+ accountOrChannel,+ imagePhysicalFile: { path: physicalFilePath },+ type,+ sendActorUpdate: true+ })+}+// ---------------------------------------------------------------------------export async function findAvailableLocalActorName (baseName: string, transaction?: Transaction) {diff --git a/server/core/lib/server-config-manager.ts b/server/core/lib/server-config-manager.tsindex b31a514206..583cacbf27 100644--- a/server/core/lib/server-config-manager.ts+++ b/server/core/lib/server-config-manager.ts@@ -549,7 +549,7 @@ class ServerConfigManager {return maxBy(this.getOpenGraphLogos(serverActor), 'width')}- getLogoUrl (serverActor: MActorUploadImages, width: 192 | 512) {+ getLogoUrl (serverActor: MActorUploadImages, width: 192 | 512 | 1500) {const customLogo = this.getLogo(serverActor, width)if (customLogo) {@@ -559,7 +559,7 @@ class ServerConfigManager {return `${WEBSERVER.URL}/client/assets/images/icons/icon-${width}x${width}.png`}- getLogo (serverActor: MActorUploadImages, width: 192 | 512) {+ getLogo (serverActor: MActorUploadImages, width: 192 | 512 | 1500) {if (serverActor.Avatars.length > 0) {return findAppropriateImage(serverActor.Avatars, width)}