diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-04-11 15:06:36 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-04-13 15:45:09 +0200 |
commit | 84bced652cd72aad852914a4a734c47dd0002fef (patch) | |
tree | fd1b5fb097c0958792be7e89fe1dec621eb0c841 /server/lib/emailer.ts | |
parent | 13fec08ba3e6dff8a4a72163d94cbdb32ad57563 (diff) | |
download | PeerTube-84bced652cd72aad852914a4a734c47dd0002fef.tar.gz PeerTube-84bced652cd72aad852914a4a734c47dd0002fef.tar.zst PeerTube-84bced652cd72aad852914a4a734c47dd0002fef.zip |
render markdown and plainify descriptions on previews
Diffstat (limited to 'server/lib/emailer.ts')
-rw-r--r-- | server/lib/emailer.ts | 22 |
1 files changed, 1 insertions, 21 deletions
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts index 9ca0d5d5b..2fad82bcc 100644 --- a/server/lib/emailer.ts +++ b/server/lib/emailer.ts | |||
@@ -5,7 +5,6 @@ import { join } from 'path' | |||
5 | import { VideoChannelModel } from '@server/models/video/video-channel' | 5 | import { VideoChannelModel } from '@server/models/video/video-channel' |
6 | import { MVideoBlacklistLightVideo, MVideoBlacklistVideo } from '@server/types/models/video/video-blacklist' | 6 | import { MVideoBlacklistLightVideo, MVideoBlacklistVideo } from '@server/types/models/video/video-blacklist' |
7 | import { MVideoImport, MVideoImportVideo } from '@server/types/models/video/video-import' | 7 | import { MVideoImport, MVideoImportVideo } from '@server/types/models/video/video-import' |
8 | import { SANITIZE_OPTIONS, TEXT_WITH_HTML_RULES } from '@shared/core-utils' | ||
9 | import { AbuseState, EmailPayload, UserAbuse } from '@shared/models' | 8 | import { AbuseState, EmailPayload, UserAbuse } from '@shared/models' |
10 | import { SendEmailDefaultOptions } from '../../shared/models/server/emailer.model' | 9 | import { SendEmailDefaultOptions } from '../../shared/models/server/emailer.model' |
11 | import { isTestInstance, root } from '../helpers/core-utils' | 10 | import { isTestInstance, root } from '../helpers/core-utils' |
@@ -15,26 +14,7 @@ import { WEBSERVER } from '../initializers/constants' | |||
15 | import { MAbuseFull, MAbuseMessage, MAccountDefault, MActorFollowActors, MActorFollowFull, MPlugin, MUser } from '../types/models' | 14 | import { MAbuseFull, MAbuseMessage, MAccountDefault, MActorFollowActors, MActorFollowFull, MPlugin, MUser } from '../types/models' |
16 | import { MCommentOwnerVideo, MVideo, MVideoAccountLight } from '../types/models/video' | 15 | import { MCommentOwnerVideo, MVideo, MVideoAccountLight } from '../types/models/video' |
17 | import { JobQueue } from './job-queue' | 16 | import { JobQueue } from './job-queue' |
18 | 17 | import { toSafeHtml } from '../helpers/markdown' | |
19 | const sanitizeHtml = require('sanitize-html') | ||
20 | const markdownItEmoji = require('markdown-it-emoji/light') | ||
21 | const MarkdownItClass = require('markdown-it') | ||
22 | const markdownIt = new MarkdownItClass('default', { linkify: true, breaks: true, html: true }) | ||
23 | |||
24 | markdownIt.enable(TEXT_WITH_HTML_RULES) | ||
25 | |||
26 | markdownIt.use(markdownItEmoji) | ||
27 | |||
28 | const toSafeHtml = text => { | ||
29 | // Restore line feed | ||
30 | const textWithLineFeed = text.replace(/<br.?\/?>/g, '\r\n') | ||
31 | |||
32 | // Convert possible markdown (emojis, emphasis and lists) to html | ||
33 | const html = markdownIt.render(textWithLineFeed) | ||
34 | |||
35 | // Convert to safe Html | ||
36 | return sanitizeHtml(html, SANITIZE_OPTIONS) | ||
37 | } | ||
38 | 18 | ||
39 | const Email = require('email-templates') | 19 | const Email = require('email-templates') |
40 | 20 | ||