X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fbots.ts;h=9e92063d4ecf1be651ece80990ef35a845b38c62;hb=3b54e5902a54c99c2968383e967370ae17bbba03;hp=63280dabbf2e14f2182c4d52ce02f2495e6eb122;hpb=f2f0eda543ab54eec0f6bcdd8ccf6e382d5cafb6;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/bots.ts b/server/controllers/bots.ts index 63280dabb..9e92063d4 100644 --- a/server/controllers/bots.ts +++ b/server/controllers/bots.ts @@ -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,