Update controllers.
This commit is contained in:
Родитель
68e471cc69
Коммит
0d416c48fc
|
@ -76,7 +76,7 @@ async function notify (req, res) {
|
|||
log.info("notification", { length: recipients.length, breachAlertName: breachAlert.Name });
|
||||
|
||||
const utmID = "breach-alert";
|
||||
const scanAnotherEmailHref = EmailUtils.getScanAnotherEmailUrl(utmID);
|
||||
const ctaHref = EmailUtils.getViewMyDashboardHref(utmID);
|
||||
const notifiedRecipients = [];
|
||||
|
||||
for (const recipient of recipients) {
|
||||
|
@ -101,9 +101,9 @@ async function notify (req, res) {
|
|||
supportedLocales,
|
||||
breachAlert,
|
||||
SERVER_URL: req.app.locals.SERVER_URL,
|
||||
scanAnotherEmailHref: scanAnotherEmailHref,
|
||||
unsubscribeUrl: EmailUtils.getUnsubscribeUrl(recipient, utmID),
|
||||
whichView: "email_partials/report",
|
||||
ctaHref: ctaHref,
|
||||
whichPartial: "email_partials/report",
|
||||
},
|
||||
);
|
||||
notifiedRecipients.push(breachedEmail);
|
||||
|
|
|
@ -92,11 +92,12 @@ async function confirmed(req, res, next, client = FxAOAuthClient) {
|
|||
);
|
||||
|
||||
const utmID = "report";
|
||||
const reportSubject = EmailUtils.getReportSubject(unsafeBreachesForEmail, req);
|
||||
|
||||
|
||||
await EmailUtils.sendEmail(
|
||||
email,
|
||||
req.fluentFormat("user-verify-email-report-subject"),
|
||||
reportSubject,
|
||||
"default_email",
|
||||
{
|
||||
supportedLocales: req.supportedLocales,
|
||||
|
@ -104,10 +105,9 @@ async function confirmed(req, res, next, client = FxAOAuthClient) {
|
|||
recipientEmail: email,
|
||||
date: req.fluentFormat(new Date()),
|
||||
unsafeBreachesForEmail: unsafeBreachesForEmail,
|
||||
scanAnotherEmailHref: EmailUtils.getScanAnotherEmailUrl(utmID),
|
||||
ctaHref: EmailUtils.getViewMyDashboardHref(utmID),
|
||||
unsubscribeUrl: EmailUtils.getUnsubscribeUrl(verifiedSubscriber, utmID),
|
||||
buttonValue: req.fluentFormat("report-scan-another-email"),
|
||||
whichView: "email_partials/report",
|
||||
whichPartial: "email_partials/report",
|
||||
}
|
||||
);
|
||||
req.session.user = verifiedSubscriber;
|
||||
|
|
|
@ -52,13 +52,13 @@ async function resendEmail(req, res) {
|
|||
const email = unverifiedEmailAddressRecord.email;
|
||||
await EmailUtils.sendEmail(
|
||||
email,
|
||||
req.fluentFormat("user-add-email-verify-subject"),
|
||||
req.fluentFormat("email-subject-verify"),
|
||||
"default_email",
|
||||
{ recipientEmail: email,
|
||||
supportedLocales: req.supportedLocales,
|
||||
verificationHref: EmailUtils.getVerificationUrl(unverifiedEmailAddressRecord),
|
||||
ctaHref: EmailUtils.getVerificationUrl(unverifiedEmailAddressRecord),
|
||||
unsubscribeUrl: EmailUtils.getUnsubscribeUrl(unverifiedEmailAddressRecord, "account-verification-email"),
|
||||
whichView: "email_partials/email_verify",
|
||||
whichPartial: "email_partials/email_verify",
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -106,14 +106,14 @@ async function add(req, res) {
|
|||
|
||||
await EmailUtils.sendEmail(
|
||||
email,
|
||||
req.fluentFormat("user-add-email-verify-subject"),
|
||||
req.fluentFormat("email-subject-verify"),
|
||||
"default_email",
|
||||
{ breachedEmail: email,
|
||||
recipientEmail: email,
|
||||
supportedLocales: req.supportedLocales,
|
||||
verificationHref: EmailUtils.getVerificationUrl(unverifiedSubscriber),
|
||||
ctaHref: EmailUtils.getVerificationUrl(unverifiedSubscriber),
|
||||
unsubscribeUrl: EmailUtils.getUnsubscribeUrl(unverifiedSubscriber, "account-verification-email"),
|
||||
whichView: "email_partials/email_verify",
|
||||
whichPartial: "email_partials/email_verify",
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -205,19 +205,21 @@ async function _verify(req) {
|
|||
);
|
||||
|
||||
const utmID = "report";
|
||||
const emailSubject = EmailUtils.getReportSubject(unsafeBreachesForEmail, req);
|
||||
|
||||
|
||||
await EmailUtils.sendEmail(
|
||||
verifiedEmailHash.email,
|
||||
req.fluentFormat("user-verify-email-report-subject"),
|
||||
emailSubject,
|
||||
"default_email",
|
||||
{
|
||||
breachedEmail: verifiedEmailHash.email,
|
||||
recipientEmail: verifiedEmailHash.email,
|
||||
supportedLocales: req.supportedLocales,
|
||||
unsafeBreachesForEmail: unsafeBreachesForEmail,
|
||||
scanAnotherEmailHref: EmailUtils.getScanAnotherEmailUrl(utmID),
|
||||
ctaHref: EmailUtils.getViewMyDashboardHref(utmID),
|
||||
unsubscribeUrl: EmailUtils.getUnsubscribeUrl(verifiedEmailHash, utmID),
|
||||
whichView: "email_partials/report",
|
||||
whichPartial: "email_partials/report",
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -92,9 +92,16 @@ const EmailUtils = {
|
|||
return url;
|
||||
},
|
||||
|
||||
getScanAnotherEmailUrl(emailType) {
|
||||
getReportSubject(breaches, req) {
|
||||
if (breaches.length === 0) {
|
||||
return req.fluentFormat("email-subject-no-breaches");
|
||||
}
|
||||
return req.fluentFormat("email-subject-found-breaches");
|
||||
},
|
||||
|
||||
getViewMyDashboardHref(emailType) {
|
||||
let url = new URL(AppConstants.SERVER_URL);
|
||||
url = this.appendUtmParams(url, "scan-another-email", emailType);
|
||||
url = this.appendUtmParams(url, "view-my-dashboard", emailType);
|
||||
return url;
|
||||
},
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче