diff options
author | Chocobozzz <me@florianbigard.com> | 2020-04-01 14:16:19 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-04-01 14:46:53 +0200 |
commit | d96994289b24c4bbd056660c5fe11fff0f77635e (patch) | |
tree | f3c21a32735b665184ee8e62e79a869f99c01a09 /server/controllers/bots.ts | |
parent | 4adebd513ec207d54e76a09cd4a8554d1900d34a (diff) | |
download | PeerTube-d96994289b24c4bbd056660c5fe11fff0f77635e.tar.gz PeerTube-d96994289b24c4bbd056660c5fe11fff0f77635e.tar.zst PeerTube-d96994289b24c4bbd056660c5fe11fff0f77635e.zip |
Update server dependencies
Diffstat (limited to 'server/controllers/bots.ts')
-rw-r--r-- | server/controllers/bots.ts | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/server/controllers/bots.ts b/server/controllers/bots.ts index 63280dabb..541b40e8e 100644 --- a/server/controllers/bots.ts +++ b/server/controllers/bots.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { asyncMiddleware } from '../middlewares' | 2 | import { asyncMiddleware } from '../middlewares' |
3 | import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' | 3 | import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' |
4 | import * as sitemapModule from 'sitemap' | 4 | import { SitemapStream, streamToPromise } from 'sitemap' |
5 | import { VideoModel } from '../models/video/video' | 5 | import { VideoModel } from '../models/video/video' |
6 | import { VideoChannelModel } from '../models/video/video-channel' | 6 | import { VideoChannelModel } from '../models/video/video-channel' |
7 | import { AccountModel } from '../models/account/account' | 7 | import { AccountModel } from '../models/account/account' |
@@ -33,12 +33,14 @@ async function getSitemap (req: express.Request, res: express.Response) { | |||
33 | urls = urls.concat(await getSitemapVideoChannelUrls()) | 33 | urls = urls.concat(await getSitemapVideoChannelUrls()) |
34 | urls = urls.concat(await getSitemapAccountUrls()) | 34 | urls = urls.concat(await getSitemapAccountUrls()) |
35 | 35 | ||
36 | const sitemap = sitemapModule.createSitemap({ | 36 | const sitemapStream = new SitemapStream({ hostname: WEBSERVER.URL }) |
37 | hostname: WEBSERVER.URL, | 37 | |
38 | urls: urls | 38 | for (const url of urls) { |
39 | }) | 39 | sitemapStream.write({ url }) |
40 | } | ||
41 | sitemapStream.end() | ||
40 | 42 | ||
41 | const xml = sitemap.toXML() | 43 | const xml = await streamToPromise(sitemapStream) |
42 | 44 | ||
43 | res.header('Content-Type', 'application/xml') | 45 | res.header('Content-Type', 'application/xml') |
44 | res.send(xml) | 46 | res.send(xml) |