]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/feeds.ts
Translated using Weblate (Polish)
[github/Chocobozzz/PeerTube.git] / server / controllers / feeds.ts
index 7207baa006b60ad300702c2183c825e8a2a6d959..fa6c7ac714869a6ecba7795fe791d83025a1c6f9 100644 (file)
@@ -56,17 +56,23 @@ async function generateVideoCommentsFeed (req: express.Request, res: express.Res
   comments.forEach(comment => {
     const link = WEBSERVER.URL + comment.getCommentStaticPath()
 
+    let title = comment.Video.name
+    const author: { name: string, link: string }[] = []
+
+    if (comment.Account) {
+      title += ` - ${comment.Account.getDisplayName()}`
+      author.push({
+        name: comment.Account.getDisplayName(),
+        link: comment.Account.Actor.url
+      })
+    }
+
     feed.addItem({
-      title: `${comment.Video.name} - ${comment.Account.getDisplayName()}`,
+      title,
       id: comment.url,
       link,
       content: comment.text,
-      author: [
-        {
-          name: comment.Account.getDisplayName(),
-          link: comment.Account.Actor.url
-        }
-      ],
+      author,
       date: comment.createdAt
     })
   })
@@ -113,22 +119,36 @@ async function generateVideoFeed (req: express.Request, res: express.Response) {
   // Adding video items to the feed, one at a time
   resultList.data.forEach(video => {
     const formattedVideoFiles = video.getFormattedVideoFilesJSON()
+
     const torrents = formattedVideoFiles.map(videoFile => ({
       title: video.name,
       url: videoFile.torrentUrl,
       size_in_bytes: videoFile.size
     }))
-    const videos = formattedVideoFiles.map(videoFile => (Object.assign({
-      type: 'video/mp4',
-      medium: 'video',
-      height: videoFile.resolution.label.replace('p', ''),
-      fileSize: videoFile.size,
-      url: videoFile.fileUrl,
-      framerate: videoFile.fps,
-      duration: video.duration
-    }, video.language ? {
-      lang: video.language
-    } : {})))
+
+    const videos = formattedVideoFiles.map(videoFile => {
+      const result = {
+        type: 'video/mp4',
+        medium: 'video',
+        height: videoFile.resolution.label.replace('p', ''),
+        fileSize: videoFile.size,
+        url: videoFile.fileUrl,
+        framerate: videoFile.fps,
+        duration: video.duration
+      }
+
+      if (video.language) Object.assign(result, { lang: video.language })
+
+      return result
+    })
+
+    const categories: { value: number, label: string }[] = []
+    if (video.category) {
+      categories.push({
+        value: video.category,
+        label: VideoModel.getCategoryLabel(video.category)
+      })
+    }
 
     feed.addItem({
       title: video.name,
@@ -153,10 +173,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response) {
       player: {
         url: video.getWatchStaticPath()
       },
-      categories: [video.category ? {
-        value: video.category,
-        label: VideoModel.getCategoryLabel(video.category)
-      } : null],
+      categories,
       community: {
         statistics: {
           views: video.views