From 1ed1994fffb18a2b0bd74e49b50067ab047f8ab8 Mon Sep 17 00:00:00 2001 From: Alecks Gates Date: Mon, 5 Jun 2023 02:00:30 -0500 Subject: Use largest avatar in RSS feeds, unique guid for liveItems (#5817) * Attempt to get largest avatar size * WIP live guid changes * Use largest avatar version in feeds * Misc variable names/import changes * Update podcast feed tests for guid changes * More testing * Lint fix * Styling --------- Co-authored-by: Chocobozzz --- server/controllers/feeds/shared/common-feed-utils.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'server/controllers/feeds/shared') diff --git a/server/controllers/feeds/shared/common-feed-utils.ts b/server/controllers/feeds/shared/common-feed-utils.ts index 375c2814b..8f35a8b35 100644 --- a/server/controllers/feeds/shared/common-feed-utils.ts +++ b/server/controllers/feeds/shared/common-feed-utils.ts @@ -1,4 +1,5 @@ import express from 'express' +import { maxBy } from 'lodash' import { Feed } from '@peertube/feed' import { CustomTag, CustomXMLNS, Person } from '@peertube/feed/lib/typings' import { mdToOneLinePlainText } from '@server/helpers/markdown' @@ -104,11 +105,13 @@ export async function buildFeedMetadata (options: { accountLink = videoChannel.Account.getClientUrl() if (videoChannel.Actor.hasImage(ActorImageType.AVATAR)) { - imageUrl = WEBSERVER.URL + videoChannel.Actor.Avatars[0].getStaticPath() + const videoChannelAvatar = maxBy(videoChannel.Actor.Avatars, 'width') + imageUrl = WEBSERVER.URL + videoChannelAvatar.getStaticPath() } if (videoChannel.Account.Actor.hasImage(ActorImageType.AVATAR)) { - accountImageUrl = WEBSERVER.URL + videoChannel.Account.Actor.Avatars[0].getStaticPath() + const accountAvatar = maxBy(videoChannel.Account.Actor.Avatars, 'width') + accountImageUrl = WEBSERVER.URL + accountAvatar.getStaticPath() } user = await UserModel.loadById(videoChannel.Account.userId) @@ -120,7 +123,8 @@ export async function buildFeedMetadata (options: { accountLink = link if (account.Actor.hasImage(ActorImageType.AVATAR)) { - imageUrl = WEBSERVER.URL + account.Actor.Avatars[0].getStaticPath() + const accountAvatar = maxBy(account.Actor.Avatars, 'width') + imageUrl = WEBSERVER.URL + accountAvatar?.getStaticPath() accountImageUrl = imageUrl } -- cgit v1.2.3