X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Femailer.ts;h=42d7650ddb76c8e60b8ba15226ca99e868385623;hb=9452d4fd3321148fb80b64a67bd9983fee6c208e;hp=6bb61484b2fe072375fa58a48f426d584f516036;hpb=d26836cd95e981d636006652927773c7943e77ce;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts index 6bb61484b..42d7650dd 100644 --- a/server/lib/emailer.ts +++ b/server/lib/emailer.ts @@ -2,9 +2,10 @@ import { readFileSync } from 'fs-extra' import { isArray, merge } from 'lodash' import { createTransport, Transporter } from 'nodemailer' import { join } from 'path' +import { root } from '@shared/core-utils' import { EmailPayload } from '@shared/models' import { SendEmailDefaultOptions } from '../../shared/models/server/emailer.model' -import { isTestInstance, root } from '../helpers/core-utils' +import { isTestOrDevInstance } from '../helpers/core-utils' import { bunyanLogger, logger } from '../helpers/logger' import { CONFIG, isEmailEnabled } from '../initializers/config' import { WEBSERVER } from '../initializers/constants' @@ -28,7 +29,7 @@ class Emailer { this.initialized = true if (!isEmailEnabled()) { - if (!isTestInstance()) { + if (!isTestOrDevInstance()) { logger.error('Cannot use SMTP server because of lack of configuration. PeerTube will not be able to send mails!') } @@ -140,6 +141,12 @@ class Emailer { const email = new Email({ send: true, + htmlToText: { + selectors: [ + { selector: 'img', format: 'skip' }, + { selector: 'a', options: { hideLinkHrefIfSameAsText: true } } + ] + }, message: { from: `"${fromDisplayName}" <${CONFIG.SMTP.FROM_ADDRESS}>` }, @@ -172,7 +179,7 @@ class Emailer { } } - // overriden/new variables given for a specific template in the payload + // overridden/new variables given for a specific template in the payload const sendOptions = merge(baseOptions, options) await email.send(sendOptions) @@ -222,7 +229,7 @@ class Emailer { sendmail: true, newline: 'unix', path: CONFIG.SMTP.SENDMAIL, - logger: bunyanLogger as any + logger: bunyanLogger }) }