-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
pr05 Typescript Migration #12: Migrate server/mail system #3648
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
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
da7834d
views/mail: update to ts, no-verify
clairep94 4100e11
add server/types/email and add types to views/mail
clairep94 483a0a5
views/mailLayout: migrate to ts, no-verify
clairep94 9149cbb
views/mailLayout: update with types and update to named export
clairep94 f627c85
views/consolidationMailLayout: migrate to ts, no-verify
clairep94 c9c2eee
views/consolidationMailLayout: add jsdocs, types and update to named …
clairep94 6a23f14
utils/renderMjml: update to ts, no-verify
clairep94 a89dc75
add mjml types package, update renderMjml with types and named export…
clairep94 7227c44
utils/mail: migrate to ts, no-verify
clairep94 ab5fa1e
add nodemailer-mailgun-transport types
clairep94 836241e
update type definitions for mailer wrapper
clairep94 a1f4cc5
utils/mail: update to named export
clairep94 b7c0ea3
Merge branch 'develop' into pr05/migrate_mail_system
khanniie 9055f36
server/utils/renderMjml: explicitly return undefined
clairep94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** Rendered mail data for the mailer service, without the 'from' property, which will be automatically added */ | ||
export interface RenderedMailerData { | ||
to: string; | ||
subject: string; | ||
html?: string; | ||
} | ||
|
||
// -------- EMAIL OPTIONS -------- | ||
/** Options to generate the account consolidation email */ | ||
export interface AccountConsolidationEmailOptions { | ||
body: { | ||
domain: string; | ||
username: string; | ||
email: string; | ||
}; | ||
to: string; | ||
} | ||
/** Options to generate the reset password email */ | ||
export interface ResetPasswordEmailOptions { | ||
body: { | ||
domain: string; | ||
link: string; | ||
}; | ||
to: string; | ||
} | ||
/** Options to generate the confirm email email */ | ||
export interface ConfirmEmailEmailOptions { | ||
body: { | ||
domain: string; | ||
link: string; | ||
}; | ||
to: string; | ||
} | ||
|
||
// -------- EMAIL RENDERING TEMPLATES -------- | ||
/** Base template for emails */ | ||
export interface BaseEmailTemplate { | ||
domain: string; | ||
headingText: string; | ||
greetingText: string; | ||
messageText: string; | ||
directLinkText: string; | ||
noteText: string; | ||
meta: { | ||
keywords: string; | ||
description: string; | ||
}; | ||
} | ||
/** Template for an email with a primary button, which contains text and a link */ | ||
export interface EmailWithPrimaryButtonTemplate extends BaseEmailTemplate { | ||
link: string; | ||
buttonText: string; | ||
} | ||
/** Template for rendering the account consolidation email */ | ||
export interface AccountConsolidationEmailTemplate extends BaseEmailTemplate { | ||
username: string; | ||
email: string; | ||
message2Text: string; | ||
resetPasswordLink: string; | ||
resetPasswordText: string; | ||
} | ||
/** Template for rendering the confirm email email */ | ||
export type ConfirmEmailEmailTemplate = EmailWithPrimaryButtonTemplate; | ||
/** Template for rendering the reset password email */ | ||
export type ResetPasswordEmailTemplate = EmailWithPrimaryButtonTemplate; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-disable consistent-return */ | ||
import mjml2html from 'mjml'; | ||
|
||
/** Parse template string containing mjml tags into html for nodemailer.SendMailOptions.html */ | ||
export function renderMjml(template: string): string | undefined { | ||
try { | ||
const output = mjml2html(template); | ||
return output.html; | ||
} catch (e) { | ||
console.error(e); | ||
// fall through to undefined (null is not valid for nodemailer.SendMailOptions.html) | ||
return undefined; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nit but can we explicitly return undefined?