diff --git a/server/emails/mailer.tsx b/server/emails/mailer.tsx index 1c9186654..ab303792d 100644 --- a/server/emails/mailer.tsx +++ b/server/emails/mailer.tsx @@ -56,6 +56,64 @@ export class Mailer { } } + template = ({ + title, + bodyContent, + headCSS = "", + bgColor = "#FFFFFF", + lang, + dir = "ltr" /* https://www.w3.org/TR/html4/struct/dirlang.html#blocklevel-bidi */, + }: Oy.CustomTemplateRenderOptions) => { + if (!title) { + throw new Error("`title` is a required option for `renderTemplate`"); + } else if (!bodyContent) { + throw new Error( + "`bodyContent` is a required option for `renderTemplate`" + ); + } + + // the template below is a slightly modified form of https://github.com/revivek/oy/blob/master/src/utils/HTML4.js + return ` + + + + + + + + ${title} + + + + + + + ${bodyContent} + + + `; + }; + sendMail = async (data: SendMailOptions): Promise => { const { transporter } = this; @@ -67,11 +125,14 @@ export class Mailer { return; } - const html = Oy.renderTemplate(data.component, { - title: data.subject, - headCSS: [baseStyles, data.headCSS].join(" "), - previewText: data.previewText ?? "", - }); + const html = Oy.renderTemplate( + data.component, + { + title: data.subject, + headCSS: [baseStyles, data.headCSS].join(" "), + } as Oy.RenderOptions, + this.template + ); try { Logger.info("email", `Sending email "${data.subject}" to ${data.to}`); diff --git a/server/emails/templates/CollectionCreatedEmail.tsx b/server/emails/templates/CollectionCreatedEmail.tsx index 143b77cf1..ad9a5fca3 100644 --- a/server/emails/templates/CollectionCreatedEmail.tsx +++ b/server/emails/templates/CollectionCreatedEmail.tsx @@ -68,8 +68,13 @@ Open Collection: ${teamUrl}${collection.url} } protected render({ collection, teamUrl, unsubscribeUrl }: Props) { + const collectionLink = `${teamUrl}${collection.url}`; + return ( - +
@@ -80,9 +85,7 @@ Open Collection: ${teamUrl}${collection.url}

- +

diff --git a/server/emails/templates/CommentCreatedEmail.tsx b/server/emails/templates/CommentCreatedEmail.tsx index e7a0f99d8..2642fb847 100644 --- a/server/emails/templates/CommentCreatedEmail.tsx +++ b/server/emails/templates/CommentCreatedEmail.tsx @@ -147,17 +147,20 @@ Open Thread: ${teamUrl}${document.url}?commentId=${commentId} unsubscribeUrl, body, }: Props) { - const link = `${teamUrl}${document.url}?commentId=${commentId}&ref=notification-email`; + const threadLink = `${teamUrl}${document.url}?commentId=${commentId}&ref=notification-email`; return ( - +
{document.title}

{actorName} {isReply ? "replied to a thread in" : "commented on"}{" "} - {document.title}{" "} + {document.title}{" "} {collection.name ? `in the ${collection.name} collection` : ""}.

{body && ( @@ -170,7 +173,7 @@ Open Thread: ${teamUrl}${document.url}?commentId=${commentId} )}

- +

diff --git a/server/emails/templates/CommentMentionedEmail.tsx b/server/emails/templates/CommentMentionedEmail.tsx index 10b4ac1e5..526bef481 100644 --- a/server/emails/templates/CommentMentionedEmail.tsx +++ b/server/emails/templates/CommentMentionedEmail.tsx @@ -130,17 +130,20 @@ Open Thread: ${teamUrl}${document.url}?commentId=${commentId} unsubscribeUrl, body, }: Props) { - const link = `${teamUrl}${document.url}?commentId=${commentId}&ref=notification-email`; + const threadLink = `${teamUrl}${document.url}?commentId=${commentId}&ref=notification-email`; return ( - +
{document.title}

{actorName} mentioned you in a comment on{" "} - {document.title}{" "} + {document.title}{" "} {collection.name ? `in the ${collection.name} collection` : ""}.

{body && ( @@ -153,7 +156,7 @@ Open Thread: ${teamUrl}${document.url}?commentId=${commentId} )}

- +

diff --git a/server/emails/templates/ConfirmUserDeleteEmail.tsx b/server/emails/templates/ConfirmUserDeleteEmail.tsx index 6aa467227..9e38d40c5 100644 --- a/server/emails/templates/ConfirmUserDeleteEmail.tsx +++ b/server/emails/templates/ConfirmUserDeleteEmail.tsx @@ -38,7 +38,7 @@ Code: ${deleteConfirmationCode} protected render({ deleteConfirmationCode }: Props) { return ( - +
diff --git a/server/emails/templates/DocumentMentionedEmail.tsx b/server/emails/templates/DocumentMentionedEmail.tsx index dd5ddaab5..d76c3e157 100644 --- a/server/emails/templates/DocumentMentionedEmail.tsx +++ b/server/emails/templates/DocumentMentionedEmail.tsx @@ -58,20 +58,23 @@ Open Document: ${teamUrl}${document.url} } protected render({ document, actorName, teamUrl }: Props) { - const link = `${teamUrl}${document.url}?ref=notification-email`; + const documentLink = `${teamUrl}${document.url}?ref=notification-email`; return ( - +
You were mentioned

{actorName} mentioned you in the document{" "} - {document.title}. + {document.title}.

- +

diff --git a/server/emails/templates/DocumentPublishedOrUpdatedEmail.tsx b/server/emails/templates/DocumentPublishedOrUpdatedEmail.tsx index e993dd67e..56949be93 100644 --- a/server/emails/templates/DocumentPublishedOrUpdatedEmail.tsx +++ b/server/emails/templates/DocumentPublishedOrUpdatedEmail.tsx @@ -144,11 +144,14 @@ Open Document: ${teamUrl}${document.url} unsubscribeUrl, body, }: Props) { - const link = `${teamUrl}${document.url}?ref=notification-email`; + const documentLink = `${teamUrl}${document.url}?ref=notification-email`; const eventName = this.eventName(eventType); return ( - +
@@ -157,8 +160,8 @@ Open Document: ${teamUrl}${document.url}

{actorName} {eventName} the document{" "} - {document.title}, in the {collection.name}{" "} - collection. + {document.title}, in the{" "} + {collection.name} collection.

{body && ( <> @@ -170,7 +173,7 @@ Open Document: ${teamUrl}${document.url} )}

- +

diff --git a/server/emails/templates/ExportFailureEmail.tsx b/server/emails/templates/ExportFailureEmail.tsx index 037786f2b..0d011071f 100644 --- a/server/emails/templates/ExportFailureEmail.tsx +++ b/server/emails/templates/ExportFailureEmail.tsx @@ -55,25 +55,23 @@ section to try again – if the problem persists please contact support. } protected render({ teamUrl, unsubscribeUrl }: Props & BeforeSendProps) { + const exportLink = `${teamUrl}/settings/export`; + return ( - +
Your Data Export

Sorry, your requested data export has failed, please visit the{" "} - + admin section . to try again – if the problem persists please contact support.

- +