]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/bots.ts
Translated using Weblate (Spanish)
[github/Chocobozzz/PeerTube.git] / server / controllers / bots.ts
index 63280dabbf2e14f2182c4d52ce02f2495e6eb122..9e92063d4ecf1be651ece80990ef35a845b38c62 100644 (file)
@@ -1,7 +1,7 @@
 import * as express from 'express'
 import { asyncMiddleware } from '../middlewares'
 import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
-import * as sitemapModule from 'sitemap'
+import { SitemapStream, streamToPromise } from 'sitemap'
 import { VideoModel } from '../models/video/video'
 import { VideoChannelModel } from '../models/video/video-channel'
 import { AccountModel } from '../models/account/account'
@@ -33,12 +33,14 @@ async function getSitemap (req: express.Request, res: express.Response) {
   urls = urls.concat(await getSitemapVideoChannelUrls())
   urls = urls.concat(await getSitemapAccountUrls())
 
-  const sitemap = sitemapModule.createSitemap({
-    hostname: WEBSERVER.URL,
-    urls: urls
-  })
+  const sitemapStream = new SitemapStream({ hostname: WEBSERVER.URL })
+
+  for (const urlObj of urls) {
+    sitemapStream.write(urlObj)
+  }
+  sitemapStream.end()
 
-  const xml = sitemap.toXML()
+  const xml = await streamToPromise(sitemapStream)
 
   res.header('Content-Type', 'application/xml')
   res.send(xml)
@@ -73,7 +75,7 @@ async function getSitemapLocalVideoUrls () {
   })
 
   return data.map(v => ({
-    url: WEBSERVER.URL + '/videos/watch/' + v.uuid,
+    url: WEBSERVER.URL + '/w/' + v.uuid,
     video: [
       {
         title: v.name,