Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(view): render view asynchronous #61

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/mail",
"version": "4.20.0",
"version": "4.21.0",
"description": "The Athenna email handler. Built on top of nodemailer.",
"license": "MIT",
"author": "Victor Tesoura Júnior <[email protected]>",
Expand Down
18 changes: 17 additions & 1 deletion src/drivers/SmtpDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ export class SmtpDriver extends Driver {
* Send a new mail message.
*/
public async send(): Promise<any> {
if (this.message.text) {
this.message.text = await Promise.resolve(this.message.text)
}

if (this.message.html) {
this.message.html = await Promise.resolve(this.message.html)
}

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
if (this.message.markdown) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
this.message.markdown = await Promise.resolve(this.message.markdown)
}

return this.transport.sendMail(this.message)
}

Expand Down Expand Up @@ -491,7 +507,7 @@ export class SmtpDriver extends Driver {
public view(name: string, data: any = {}, options: ContentOptions = {}) {
options = Options.create(options, { type: 'html' })

this.message[options.type] = View.renderSync(name, {
this.message[options.type] = View.render(name, {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
content: this.message.text || this.message.html || this.message.markdown,
Expand Down
Loading