]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/feeds/shared/common-feed-utils.ts
Fix undefined actor image
[github/Chocobozzz/PeerTube.git] / server / controllers / feeds / shared / common-feed-utils.ts
index 8f35a8b350f2708b0e7835e1b575ba59e501f095..9e2f8adbbf41f5e000bf1bf19a15dcafffaa911b 100644 (file)
@@ -1,10 +1,10 @@
 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'
 import { CONFIG } from '@server/initializers/config'
 import { WEBSERVER } from '@server/initializers/constants'
+import { getBiggestActorImage } from '@server/lib/actor-image'
 import { UserModel } from '@server/models/user/user'
 import { MAccountDefault, MChannelBannerAccountDefault, MUser, MVideoFullLight } from '@server/types/models'
 import { pick } from '@shared/core-utils'
@@ -105,12 +105,12 @@ export async function buildFeedMetadata (options: {
     accountLink = videoChannel.Account.getClientUrl()
 
     if (videoChannel.Actor.hasImage(ActorImageType.AVATAR)) {
-      const videoChannelAvatar = maxBy(videoChannel.Actor.Avatars, 'width')
+      const videoChannelAvatar = getBiggestActorImage(videoChannel.Actor.Avatars)
       imageUrl = WEBSERVER.URL + videoChannelAvatar.getStaticPath()
     }
 
     if (videoChannel.Account.Actor.hasImage(ActorImageType.AVATAR)) {
-      const accountAvatar = maxBy(videoChannel.Account.Actor.Avatars, 'width')
+      const accountAvatar = getBiggestActorImage(videoChannel.Account.Actor.Avatars)
       accountImageUrl = WEBSERVER.URL + accountAvatar.getStaticPath()
     }
 
@@ -123,7 +123,7 @@ export async function buildFeedMetadata (options: {
     accountLink = link
 
     if (account.Actor.hasImage(ActorImageType.AVATAR)) {
-      const accountAvatar = maxBy(account.Actor.Avatars, 'width')
+      const accountAvatar = getBiggestActorImage(account.Actor.Avatars)
       imageUrl = WEBSERVER.URL + accountAvatar?.getStaticPath()
       accountImageUrl = imageUrl
     }