aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-09-27 16:19:36 +0200
committerChocobozzz <me@florianbigard.com>2022-09-27 16:19:36 +0200
commit2b32c5b37e0b10261a108cc7c23b72d64f806576 (patch)
treef7977ac5d198802a13826a7faf37a15eb45c09c8 /server/controllers
parentaca96f8007a5be97b7cfa36e3fee0b7003b1bcf5 (diff)
downloadPeerTube-2b32c5b37e0b10261a108cc7c23b72d64f806576.tar.gz
PeerTube-2b32c5b37e0b10261a108cc7c23b72d64f806576.tar.zst
PeerTube-2b32c5b37e0b10261a108cc7c23b72d64f806576.zip
Fix InvalidVideoTitle console warning
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/bots.ts19
1 files changed, 16 insertions, 3 deletions
diff --git a/server/controllers/bots.ts b/server/controllers/bots.ts
index 2a8d6863a..a5ce1d79f 100644
--- a/server/controllers/bots.ts
+++ b/server/controllers/bots.ts
@@ -1,7 +1,8 @@
1import { getServerActor } from '@server/models/application/application' 1import { getServerActor } from '@server/models/application/application'
2import { logger } from '@uploadx/core'
2import express from 'express' 3import express from 'express'
3import { truncate } from 'lodash' 4import { truncate } from 'lodash'
4import { SitemapStream, streamToPromise } from 'sitemap' 5import { SitemapStream, streamToPromise, ErrorLevel } from 'sitemap'
5import { buildNSFWFilter } from '../helpers/express-utils' 6import { buildNSFWFilter } from '../helpers/express-utils'
6import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' 7import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
7import { asyncMiddleware } from '../middlewares' 8import { asyncMiddleware } from '../middlewares'
@@ -34,7 +35,18 @@ async function getSitemap (req: express.Request, res: express.Response) {
34 urls = urls.concat(await getSitemapVideoChannelUrls()) 35 urls = urls.concat(await getSitemapVideoChannelUrls())
35 urls = urls.concat(await getSitemapAccountUrls()) 36 urls = urls.concat(await getSitemapAccountUrls())
36 37
37 const sitemapStream = new SitemapStream({ hostname: WEBSERVER.URL }) 38 const sitemapStream = new SitemapStream({
39 hostname: WEBSERVER.URL,
40 errorHandler: (err: Error, level: ErrorLevel) => {
41 if (level === 'warn') {
42 logger.warn('Warning in sitemap generation.', { err })
43 } else if (level === 'throw') {
44 logger.error('Error in sitemap generation.', { err })
45
46 throw err
47 }
48 }
49 })
38 50
39 for (const urlObj of urls) { 51 for (const urlObj of urls) {
40 sitemapStream.write(urlObj) 52 sitemapStream.write(urlObj)
@@ -83,7 +95,8 @@ async function getSitemapLocalVideoUrls () {
83 url: WEBSERVER.URL + v.getWatchStaticPath(), 95 url: WEBSERVER.URL + v.getWatchStaticPath(),
84 video: [ 96 video: [
85 { 97 {
86 title: v.name, 98 // Sitemap title should be < 100 characters
99 title: truncate(v.name, { length: 100, omission: '...' }),
87 // Sitemap description should be < 2000 characters 100 // Sitemap description should be < 2000 characters
88 description: truncate(v.description || v.name, { length: 2000, omission: '...' }), 101 description: truncate(v.description || v.name, { length: 2000, omission: '...' }),
89 player_loc: WEBSERVER.URL + v.getEmbedStaticPath(), 102 player_loc: WEBSERVER.URL + v.getEmbedStaticPath(),