Skip to content

Commit

Permalink
✨ Send HTML content in email (#1589)
Browse files Browse the repository at this point in the history
* ✨ Send HTML content in email

* ✨ Use html-to-text plugin for moderation mailer transport

* type fix

---------

Co-authored-by: Devin Ivy <[email protected]>
  • Loading branch information
foysalit and devinivy authored Oct 3, 2023
1 parent 647ca6a commit 26538a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/pds/src/api/app/bsky/feed/getPostThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand Down
10 changes: 7 additions & 3 deletions packages/pds/src/mailer/moderation.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -14,14 +15,17 @@ export class ModerationMailer {
) {
this.config = config
this.transporter = transporter
this.transporter.use('compile', htmlToText())
}

async send({ content }: { content: string }, mailOpts: Mail.Options) {
const res = await this.transporter.sendMail({
const mail = {
...mailOpts,
text: content,
html: content,
from: this.config.moderationEmail?.fromAddress,
})
}

const res = await this.transporter.sendMail(mail)

if (!this.config.moderationEmail?.smtpUrl) {
mailerLogger.debug(
Expand Down

0 comments on commit 26538a7

Please sign in to comment.