Просмотр исходного кода

Merge pull request #1928 from overleaf/jel-email-after-registration

Send welcome email after registration

GitOrigin-RevId: 1f2b34299e6f4a1e4e44c100711e8f3b8db54595
Simon Detheridge 7 лет назад
Родитель
Сommit
02a4289422

+ 56 - 0
services/web/app/src/Features/Email/Bodies/NoCTAEmailBody.js

@@ -0,0 +1,56 @@
+const _ = require('underscore')
+
+module.exports = _.template(`\
+	<table class="row" style="border-collapse: collapse; border-spacing: 0; display: table; padding: 0; position: relative; text-align: left; vertical-align: top; width: 100%;">
+		<tbody>
+			<tr style="padding: 0; vertical-align: top;">
+				<th class="small-12 columns" style="margin: 0 auto; line-height: 1.3; margin: 0 auto; padding: 0; padding-bottom: 16px; padding-left: 16px; padding-right: 16px; text-align: left; width: 564px;">
+					<table style="border-collapse: collapse; border-spacing: 0; padding: 0; text-align: left; vertical-align: top; width: 100%; color: #5D6879; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: normal; line-height: 1.3;"><tr style="padding: 0; text-align: left; vertical-align: top;">
+						<th style="margin: 0; margin: 0; padding: 0; text-align: left;">
+							<% if (title) { %>
+								<h3 class="avoid-auto-linking" style="margin: 0; color: #5D6879; font-family: Georgia, serif; font-size: 24px; font-weight: normal; line-height: 1.3; margin: 0; padding: 0; text-align: left; word-wrap: normal;">
+									<%= title %>
+								</h3>
+							<% } %>
+						</th>
+						<tr><td>
+							<p style="height: 20px; margin: 0; padding: 0;">&#xA0;</p>
+
+							<% if (greeting) { %>
+								<p style="margin: 0 10px 0 0; padding: 0;">
+									<%= greeting %>
+								</p>
+							<% } %>
+
+							<p class="avoid-auto-linking" style="margin: 0 10px 0 0; padding: 0;">
+								<%= message %>
+							</p>
+
+							<% if (secondaryMessage) { %>
+								<p class="avoid-auto-linking" style="margin: 0 10px 0 0; padding: 0;">
+									<%= secondaryMessage %>
+								</p>
+							<% } %>
+						</td></tr>
+					</tr>
+				</table>
+			</th>
+	</tr></tbody></table>
+<% if (gmailGoToAction) { %>
+	<script type="application/ld+json">
+		<%=
+			StringHelper.stringifyJsonForScript({
+				"@context": "http://schema.org",
+				"@type": "EmailMessage",
+				"potentialAction": {
+					"@type": "ViewAction",
+					"target": gmailGoToAction.target,
+					"url": gmailGoToAction.target,
+					"name": gmailGoToAction.name
+				},
+				"description": gmailGoToAction.description
+			})
+    %>
+	</script>
+<% } %>\
+`)

+ 43 - 0
services/web/app/src/Features/Email/EmailBuilder.js

@@ -74,6 +74,48 @@ The ${settings.appName} Team - ${settings.siteUrl}\
   }
 }
 
+// No CTA Email
+const NoCTAEmailBody = require(`./Bodies/NoCTAEmailBody`)
+const NoCTAEmailTemplate = function(content) {
+  if (content.greeting == null) {
+    content.greeting = () => 'Hi,'
+  }
+  if (content.secondaryMessage == null) {
+    content.secondaryMessage = () => ''
+  }
+  return {
+    subject(opts) {
+      return content.subject(opts)
+    },
+    layout: BaseWithHeaderEmailLayout,
+    plainTextTemplate(opts) {
+      return `\
+${content.greeting(opts)}
+${content.message(opts).trim()}
+${(typeof content.secondaryMessage === 'function'
+        ? content.secondaryMessage(opts).trim()
+        : undefined) || ''}
+Regards,
+The ${settings.appName} Team - ${settings.siteUrl}\
+`
+    },
+    compiledTemplate(opts) {
+      return NoCTAEmailBody({
+        title:
+          typeof content.title === 'function' ? content.title(opts) : undefined,
+        greeting: content.greeting(opts),
+        message: marked(content.message(opts).trim()),
+        secondaryMessage: marked(content.secondaryMessage(opts).trim()),
+        gmailGoToAction:
+          typeof content.gmailGoToAction === 'function'
+            ? content.gmailGoToAction(opts)
+            : undefined,
+        StringHelper
+      })
+    }
+  }
+}
+
 const templates = {}
 
 templates.accountMergeToOverleafAddress = CTAEmailTemplate({
@@ -423,6 +465,7 @@ If you have any questions, you can contact our support team by reply.\
 module.exports = {
   templates,
   CTAEmailTemplate,
+  NoCTAEmailTemplate,
   buildEmail(templateName, opts) {
     const template = templates[templateName]
     opts.siteUrl = settings.siteUrl