aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/client-html.ts16
1 files changed, 4 insertions, 12 deletions
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)