diff options
author | Chocobozzz <me@florianbigard.com> | 2022-03-08 11:34:15 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-03-08 11:39:56 +0100 |
commit | cc45cc9ac1d0afbe4844c34b13dd4a65dd523be1 (patch) | |
tree | 11417242ae9f6d359fb68a92214fc8565b3b44d2 /server/lib | |
parent | 7b51ede977c299a74728171d8c124bcc4cbba6ea (diff) | |
download | PeerTube-cc45cc9ac1d0afbe4844c34b13dd4a65dd523be1.tar.gz PeerTube-cc45cc9ac1d0afbe4844c34b13dd4a65dd523be1.tar.zst PeerTube-cc45cc9ac1d0afbe4844c34b13dd4a65dd523be1.zip |
Remove uneeded memoize
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/client-html.ts | 16 |
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 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { readFile } from 'fs-extra' | 2 | import { readFile } from 'fs-extra' |
3 | import memoizee from 'memoizee' | ||
4 | import { join } from 'path' | 3 | import { join } from 'path' |
5 | import validator from 'validator' | 4 | import validator from 'validator' |
6 | import { toCompleteUUID } from '@server/helpers/custom-validators/misc' | 5 | import { toCompleteUUID } from '@server/helpers/custom-validators/misc' |
6 | import { mdToOneLinePlainText } from '@server/helpers/markdown' | ||
7 | import { ActorImageModel } from '@server/models/actor/actor-image' | 7 | import { ActorImageModel } from '@server/models/actor/actor-image' |
8 | import { root } from '@shared/core-utils' | 8 | import { root } from '@shared/core-utils' |
9 | import { escapeHTML } from '@shared/core-utils/renderer' | 9 | import { escapeHTML } from '@shared/core-utils/renderer' |
@@ -14,15 +14,12 @@ import { HttpStatusCode } from '../../shared/models/http/http-error-codes' | |||
14 | import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos' | 14 | import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos' |
15 | import { isTestInstance } from '../helpers/core-utils' | 15 | import { isTestInstance } from '../helpers/core-utils' |
16 | import { logger } from '../helpers/logger' | 16 | import { logger } from '../helpers/logger' |
17 | import { mdToOneLinePlainText } from '../helpers/markdown' | ||
18 | import { CONFIG } from '../initializers/config' | 17 | import { CONFIG } from '../initializers/config' |
19 | import { | 18 | import { |
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' | |||
35 | import { getBiggestActorImage } from './actor-image' | 32 | import { getBiggestActorImage } from './actor-image' |
36 | import { ServerConfigManager } from './server-config-manager' | 33 | import { ServerConfigManager } from './server-config-manager' |
37 | 34 | ||
38 | const 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 | |||
43 | type Tags = { | 35 | type 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) |