aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--scripts/benchmark.ts2
-rw-r--r--server/initializers/constants.ts4
-rw-r--r--server/lib/client-html.ts16
3 files changed, 6 insertions, 16 deletions
diff --git a/scripts/benchmark.ts b/scripts/benchmark.ts
index c9486eb37..48e740dff 100644
--- a/scripts/benchmark.ts
+++ b/scripts/benchmark.ts
@@ -215,7 +215,7 @@ async function prepare () {
215 language: 'fr', 215 language: 'fr',
216 privacy: VideoPrivacy.PUBLIC, 216 privacy: VideoPrivacy.PUBLIC,
217 support: 'please give me a coffee', 217 support: 'please give me a coffee',
218 description: 'my super description'.repeat(10), 218 description: 'my super description\n'.repeat(10) + ' * list1\n * list 2\n * list 3',
219 tags: [ 'tag1', 'tag2', 'tag3' ] 219 tags: [ 'tag1', 'tag2', 'tag3' ]
220 } 220 }
221 221
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 3069e2353..7bc2877aa 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -718,12 +718,10 @@ const MEMOIZE_TTL = {
718 OVERVIEWS_SAMPLE: 1000 * 3600 * 4, // 4 hours 718 OVERVIEWS_SAMPLE: 1000 * 3600 * 4, // 4 hours
719 INFO_HASH_EXISTS: 1000 * 3600 * 12, // 12 hours 719 INFO_HASH_EXISTS: 1000 * 3600 * 12, // 12 hours
720 LIVE_ABLE_TO_UPLOAD: 1000 * 60, // 1 minute 720 LIVE_ABLE_TO_UPLOAD: 1000 * 60, // 1 minute
721 LIVE_CHECK_SOCKET_HEALTH: 1000 * 60, // 1 minute 721 LIVE_CHECK_SOCKET_HEALTH: 1000 * 60 // 1 minute
722 MD_TO_PLAIN_TEXT_CLIENT_HTML: 1000 * 60 // 1 minute
723} 722}
724 723
725const MEMOIZE_LENGTH = { 724const MEMOIZE_LENGTH = {
726 MD_TO_PLAIN_TEXT_CLIENT_HTML: 100,
727 INFO_HASH_EXISTS: 200 725 INFO_HASH_EXISTS: 200
728} 726}
729 727
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index 945bc712f..0142b248b 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -1,9 +1,9 @@
1import express from 'express' 1import express from 'express'
2import { readFile } from 'fs-extra' 2import { readFile } from 'fs-extra'
3import memoizee from 'memoizee'
4import { join } from 'path' 3import { join } from 'path'
5import validator from 'validator' 4import validator from 'validator'
6import { toCompleteUUID } from '@server/helpers/custom-validators/misc' 5import { toCompleteUUID } from '@server/helpers/custom-validators/misc'
6import { mdToOneLinePlainText } from '@server/helpers/markdown'
7import { ActorImageModel } from '@server/models/actor/actor-image' 7import { ActorImageModel } from '@server/models/actor/actor-image'
8import { root } from '@shared/core-utils' 8import { root } from '@shared/core-utils'
9import { escapeHTML } from '@shared/core-utils/renderer' 9import { escapeHTML } from '@shared/core-utils/renderer'
@@ -14,15 +14,12 @@ import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
14import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos' 14import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos'
15import { isTestInstance } from '../helpers/core-utils' 15import { isTestInstance } from '../helpers/core-utils'
16import { logger } from '../helpers/logger' 16import { logger } from '../helpers/logger'
17import { mdToOneLinePlainText } from '../helpers/markdown'
18import { CONFIG } from '../initializers/config' 17import { CONFIG } from '../initializers/config'
19import { 18import {
20 ACCEPT_HEADERS, 19 ACCEPT_HEADERS,
21 CUSTOM_HTML_TAG_COMMENTS, 20 CUSTOM_HTML_TAG_COMMENTS,
22 EMBED_SIZE, 21 EMBED_SIZE,
23 FILES_CONTENT_HASH, 22 FILES_CONTENT_HASH,
24 MEMOIZE_LENGTH,
25 MEMOIZE_TTL,
26 PLUGIN_GLOBAL_CSS_PATH, 23 PLUGIN_GLOBAL_CSS_PATH,
27 WEBSERVER 24 WEBSERVER
28} from '../initializers/constants' 25} from '../initializers/constants'
@@ -35,11 +32,6 @@ import { MAccountActor, MChannelActor } from '../types/models'
35import { getBiggestActorImage } from './actor-image' 32import { getBiggestActorImage } from './actor-image'
36import { ServerConfigManager } from './server-config-manager' 33import { ServerConfigManager } from './server-config-manager'
37 34
38const getPlainTextDescriptionCached = memoizee(mdToOneLinePlainText, {
39 maxAge: MEMOIZE_TTL.MD_TO_PLAIN_TEXT_CLIENT_HTML,
40 max: MEMOIZE_LENGTH.MD_TO_PLAIN_TEXT_CLIENT_HTML
41})
42
43type Tags = { 35type Tags = {
44 ogType: string 36 ogType: string
45 twitterCard: 'player' | 'summary' | 'summary_large_image' 37 twitterCard: 'player' | 'summary' | 'summary_large_image'
@@ -112,7 +104,7 @@ class ClientHtml {
112 res.status(HttpStatusCode.NOT_FOUND_404) 104 res.status(HttpStatusCode.NOT_FOUND_404)
113 return html 105 return html
114 } 106 }
115 const description = getPlainTextDescriptionCached(video.description) 107 const description = mdToOneLinePlainText(video.description)
116 108
117 let customHtml = ClientHtml.addTitleTag(html, video.name) 109 let customHtml = ClientHtml.addTitleTag(html, video.name)
118 customHtml = ClientHtml.addDescriptionTag(customHtml, description) 110 customHtml = ClientHtml.addDescriptionTag(customHtml, description)
@@ -173,7 +165,7 @@ class ClientHtml {
173 return html 165 return html
174 } 166 }
175 167
176 const description = getPlainTextDescriptionCached(videoPlaylist.description) 168 const description = mdToOneLinePlainText(videoPlaylist.description)
177 169
178 let customHtml = ClientHtml.addTitleTag(html, videoPlaylist.name) 170 let customHtml = ClientHtml.addTitleTag(html, videoPlaylist.name)
179 customHtml = ClientHtml.addDescriptionTag(customHtml, description) 171 customHtml = ClientHtml.addDescriptionTag(customHtml, description)
@@ -272,7 +264,7 @@ class ClientHtml {
272 return ClientHtml.getIndexHTML(req, res) 264 return ClientHtml.getIndexHTML(req, res)
273 } 265 }
274 266
275 const description = getPlainTextDescriptionCached(entity.description) 267 const description = mdToOneLinePlainText(entity.description)
276 268
277 let customHtml = ClientHtml.addTitleTag(html, entity.getDisplayName()) 269 let customHtml = ClientHtml.addTitleTag(html, entity.getDisplayName())
278 customHtml = ClientHtml.addDescriptionTag(customHtml, description) 270 customHtml = ClientHtml.addDescriptionTag(customHtml, description)