From 5d6011c4c43c73d94f078d0f75d5370066207103 Mon Sep 17 00:00:00 2001 From: Foysal Ahamed Date: Tue, 12 Sep 2023 18:31:11 +0200 Subject: [PATCH 1/3] :sparkles: Send HTML content in email --- packages/pds/src/mailer/moderation.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/pds/src/mailer/moderation.ts b/packages/pds/src/mailer/moderation.ts index 6d77d7853c9..44a5b368ecc 100644 --- a/packages/pds/src/mailer/moderation.ts +++ b/packages/pds/src/mailer/moderation.ts @@ -16,12 +16,23 @@ export class ModerationMailer { this.transporter = transporter } + isContentHtml(content: string): boolean { + return /<\/?[a-z][\s\S]*>/i.test(content) + } + async send({ content }: { content: string }, mailOpts: Mail.Options) { - const res = await this.transporter.sendMail({ + const mail = { ...mailOpts, - text: content, from: this.config.moderationEmailAddress, - }) + } + + if (this.isContentHtml(content)) { + mail.html = content + } else { + mail.text = content + } + + const res = await this.transporter.sendMail(mail) if (!this.config.moderationEmailSmtpUrl) { mailerLogger.debug( From a924f6218c5a72492809d7088a8b417850712db5 Mon Sep 17 00:00:00 2001 From: Foysal Ahamed Date: Wed, 20 Sep 2023 17:35:47 +0200 Subject: [PATCH 2/3] :sparkles: Use html-to-text plugin for moderation mailer transport --- packages/pds/src/mailer/moderation.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/pds/src/mailer/moderation.ts b/packages/pds/src/mailer/moderation.ts index 44a5b368ecc..ac876d21812 100644 --- a/packages/pds/src/mailer/moderation.ts +++ b/packages/pds/src/mailer/moderation.ts @@ -1,5 +1,6 @@ import { Transporter } from 'nodemailer' import Mail from 'nodemailer/lib/mailer' +import { htmlToText } from 'nodemailer-html-to-text' import SMTPTransport from 'nodemailer/lib/smtp-transport' import { ServerConfig } from '../config' import { mailerLogger } from '../logger' @@ -14,24 +15,16 @@ export class ModerationMailer { ) { this.config = config this.transporter = transporter - } - - isContentHtml(content: string): boolean { - return /<\/?[a-z][\s\S]*>/i.test(content) + this.transporter.use('compile', htmlToText()) } async send({ content }: { content: string }, mailOpts: Mail.Options) { const mail = { ...mailOpts, + html: content, from: this.config.moderationEmailAddress, } - if (this.isContentHtml(content)) { - mail.html = content - } else { - mail.text = content - } - const res = await this.transporter.sendMail(mail) if (!this.config.moderationEmailSmtpUrl) { From d049059f60e3b381c4e85ed6f769ccc47b126be4 Mon Sep 17 00:00:00 2001 From: Devin Ivy Date: Tue, 3 Oct 2023 11:08:56 -0400 Subject: [PATCH 3/3] type fix --- packages/pds/src/api/app/bsky/feed/getPostThread.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pds/src/api/app/bsky/feed/getPostThread.ts b/packages/pds/src/api/app/bsky/feed/getPostThread.ts index ab9e0bc0681..270c1044497 100644 --- a/packages/pds/src/api/app/bsky/feed/getPostThread.ts +++ b/packages/pds/src/api/app/bsky/feed/getPostThread.ts @@ -32,7 +32,7 @@ export default function (server: Server, ctx: AppContext) { auth.credentials.type === 'access' ? auth.credentials.did : null if (!requester) { - const res = await ctx.appviewAgent.api.app.bsky.feed.getPostThread( + const res = await ctx.appViewAgent.api.app.bsky.feed.getPostThread( params, authPassthru(req), )