]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/feeds/video-podcast-feeds.ts
Use largest avatar in RSS feeds, unique guid for liveItems (#5817)
[github/Chocobozzz/PeerTube.git] / server / controllers / feeds / video-podcast-feeds.ts
index 45d31c7812b14d3055d6d2391cc207bf9fed60e2..f63f6ee63e6c6d4a732d27301f275961ba741a1c 100644 (file)
@@ -1,4 +1,5 @@
 import express from 'express'
+import { maxBy } from 'lodash'
 import { extname } from 'path'
 import { Feed } from '@peertube/feed'
 import { CustomTag, CustomXMLNS, LiveItemStatus } from '@peertube/feed/lib/typings'
@@ -141,8 +142,21 @@ async function generatePodcastItem (options: {
     href: account.getClientUrl()
   }
 
+  const commonAttributes = getCommonVideoFeedAttributes(video)
+  const guid = liveItem
+    ? `${video.uuid}_${video.publishedAt.toISOString()}`
+    : commonAttributes.link
+
+  let personImage: string
+
+  if (account.Actor.hasImage(ActorImageType.AVATAR)) {
+    const avatar = maxBy(account.Actor.Avatars, 'width')
+    personImage = WEBSERVER.URL + avatar.getStaticPath()
+  }
+
   return {
-    ...getCommonVideoFeedAttributes(video),
+    guid,
+    ...commonAttributes,
 
     trackers: video.getTrackerUrls(),
 
@@ -151,9 +165,7 @@ async function generatePodcastItem (options: {
       {
         ...author,
 
-        img: account.Actor.hasImage(ActorImageType.AVATAR)
-          ? WEBSERVER.URL + account.Actor.Avatars[0].getStaticPath()
-          : undefined
+        img: personImage
       }
     ],