aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/emailer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/emailer.ts')
-rw-r--r--server/lib/emailer.ts32
1 files changed, 3 insertions, 29 deletions
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index 40f278608..650a3c090 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -5,6 +5,7 @@ import { join } from 'path'
5import { VideoChannelModel } from '@server/models/video/video-channel' 5import { VideoChannelModel } from '@server/models/video/video-channel'
6import { MVideoBlacklistLightVideo, MVideoBlacklistVideo } from '@server/types/models/video/video-blacklist' 6import { MVideoBlacklistLightVideo, MVideoBlacklistVideo } from '@server/types/models/video/video-blacklist'
7import { MVideoImport, MVideoImportVideo } from '@server/types/models/video/video-import' 7import { MVideoImport, MVideoImportVideo } from '@server/types/models/video/video-import'
8import { SANITIZE_OPTIONS, TEXT_WITH_HTML_RULES } from '@shared/core-utils'
8import { AbuseState, EmailPayload, UserAbuse } from '@shared/models' 9import { AbuseState, EmailPayload, UserAbuse } from '@shared/models'
9import { SendEmailOptions } from '../../shared/models/server/emailer.model' 10import { SendEmailOptions } from '../../shared/models/server/emailer.model'
10import { isTestInstance, root } from '../helpers/core-utils' 11import { isTestInstance, root } from '../helpers/core-utils'
@@ -20,14 +21,7 @@ const markdownItEmoji = require('markdown-it-emoji/light')
20const MarkdownItClass = require('markdown-it') 21const MarkdownItClass = require('markdown-it')
21const markdownIt = new MarkdownItClass('default', { linkify: true, breaks: true, html: true }) 22const markdownIt = new MarkdownItClass('default', { linkify: true, breaks: true, html: true })
22 23
23markdownIt.enable([ 24markdownIt.enable(TEXT_WITH_HTML_RULES)
24 'linkify',
25 'autolink',
26 'emphasis',
27 'link',
28 'newline',
29 'list'
30])
31 25
32markdownIt.use(markdownItEmoji) 26markdownIt.use(markdownItEmoji)
33 27
@@ -39,27 +33,7 @@ const toSafeHtml = text => {
39 const html = markdownIt.render(textWithLineFeed) 33 const html = markdownIt.render(textWithLineFeed)
40 34
41 // Convert to safe Html 35 // Convert to safe Html
42 return sanitizeHtml(html, { 36 return sanitizeHtml(html, SANITIZE_OPTIONS)
43 allowedTags: [ 'a', 'p', 'span', 'br', 'strong', 'em', 'ul', 'ol', 'li' ],
44 allowedSchemes: [ 'http', 'https' ],
45 allowedAttributes: {
46 a: [ 'href', 'class', 'target', 'rel' ]
47 },
48 transformTags: {
49 a: (tagName, attribs) => {
50 let rel = 'noopener noreferrer'
51 if (attribs.rel === 'me') rel += ' me'
52
53 return {
54 tagName,
55 attribs: Object.assign(attribs, {
56 target: '_blank',
57 rel
58 })
59 }
60 }
61 }
62 })
63} 37}
64 38
65const Email = require('email-templates') 39const Email = require('email-templates')