diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/bots.ts | 19 | ||||
-rw-r--r-- | server/tests/api/notifications/moderation-notifications.ts | 2 | ||||
-rw-r--r-- | server/tests/misc-endpoints.ts | 18 |
3 files changed, 35 insertions, 4 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 @@ | |||
1 | import { getServerActor } from '@server/models/application/application' | 1 | import { getServerActor } from '@server/models/application/application' |
2 | import { logger } from '@uploadx/core' | ||
2 | import express from 'express' | 3 | import express from 'express' |
3 | import { truncate } from 'lodash' | 4 | import { truncate } from 'lodash' |
4 | import { SitemapStream, streamToPromise } from 'sitemap' | 5 | import { SitemapStream, streamToPromise, ErrorLevel } from 'sitemap' |
5 | import { buildNSFWFilter } from '../helpers/express-utils' | 6 | import { buildNSFWFilter } from '../helpers/express-utils' |
6 | import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' | 7 | import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' |
7 | import { asyncMiddleware } from '../middlewares' | 8 | import { 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(), |
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index da9bd1196..fc953f144 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts | |||
@@ -601,7 +601,7 @@ describe('Test moderation notifications', function () { | |||
601 | }) | 601 | }) |
602 | 602 | ||
603 | it('Should not send a notification to moderators on new video without auto-blacklist', async function () { | 603 | it('Should not send a notification to moderators on new video without auto-blacklist', async function () { |
604 | this.timeout(60000) | 604 | this.timeout(120000) |
605 | 605 | ||
606 | const name = 'video without auto-blacklist ' + buildUUID() | 606 | const name = 'video without auto-blacklist ' + buildUUID() |
607 | 607 | ||
diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts index 9e404b549..663ac044a 100644 --- a/server/tests/misc-endpoints.ts +++ b/server/tests/misc-endpoints.ts | |||
@@ -3,6 +3,7 @@ | |||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | 4 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
5 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | 5 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' |
6 | import { expectLogDoesNotContain } from './shared' | ||
6 | 7 | ||
7 | describe('Test misc endpoints', function () { | 8 | describe('Test misc endpoints', function () { |
8 | let server: PeerTubeServer | 9 | let server: PeerTubeServer |
@@ -183,6 +184,23 @@ describe('Test misc endpoints', function () { | |||
183 | expect(res.text).to.contain('<url><loc>http://localhost:' + server.port + '/accounts/user1</loc></url>') | 184 | expect(res.text).to.contain('<url><loc>http://localhost:' + server.port + '/accounts/user1</loc></url>') |
184 | expect(res.text).to.contain('<url><loc>http://localhost:' + server.port + '/accounts/user2</loc></url>') | 185 | expect(res.text).to.contain('<url><loc>http://localhost:' + server.port + '/accounts/user2</loc></url>') |
185 | }) | 186 | }) |
187 | |||
188 | it('Should not fail with big title/description videos', async function () { | ||
189 | const name = 'v'.repeat(115) | ||
190 | |||
191 | await server.videos.upload({ attributes: { name, description: 'd'.repeat(2500), nsfw: false } }) | ||
192 | |||
193 | const res = await makeGetRequest({ | ||
194 | url: server.url, | ||
195 | path: '/sitemap.xml?t=2', // avoid using cache | ||
196 | expectedStatus: HttpStatusCode.OK_200 | ||
197 | }) | ||
198 | |||
199 | await expectLogDoesNotContain(server, 'Warning in sitemap generation') | ||
200 | await expectLogDoesNotContain(server, 'Error in sitemap generation') | ||
201 | |||
202 | expect(res.text).to.contain(`<video:title>${'v'.repeat(97)}...</video:title>`) | ||
203 | }) | ||
186 | }) | 204 | }) |
187 | 205 | ||
188 | after(async function () { | 206 | after(async function () { |