fix locale-utils unsupported lang uncaught err
This commit is contained in:
Родитель
155cf4cf39
Коммит
99681c7c60
|
@ -122,10 +122,12 @@ function previewEmail2022 (req, res) {
|
|||
|
||||
function sendTestEmail (data) {
|
||||
return async function (req, res) {
|
||||
const subject = LocaleUtils.fluentFormat(req.supportedLocales, data.subjectId)
|
||||
// const supportedLocales = [req.user.signup_language, 'en'].filter(Boolean) // filter potential nullish signup_language, fallback to en
|
||||
const supportedLocales = req.supportedLocales // this varies from send-email-to-unresolved-breach-subscribers.js (the line above) in order for QA to switch lang from browser
|
||||
const subject = LocaleUtils.fluentFormat(supportedLocales, data.subjectId)
|
||||
const context = {
|
||||
whichPartial: data.whichPartial,
|
||||
supportedLocales: req.supportedLocales,
|
||||
supportedLocales,
|
||||
primaryEmail: req.user.primary_email,
|
||||
breachStats: req.user.breach_stats
|
||||
}
|
||||
|
|
|
@ -67,9 +67,11 @@ const LocaleUtils = {
|
|||
fluentFormat (supportedLocales, id, args = null, errors = null) {
|
||||
for (const locale of supportedLocales) {
|
||||
const bundle = fluentBundles[locale]
|
||||
if (bundle.hasMessage(id)) {
|
||||
try {
|
||||
const message = bundle.getMessage(id)
|
||||
return bundle.format(message, args)
|
||||
} catch (e) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
return id
|
||||
|
|
|
@ -6,7 +6,7 @@ async function sendUnresolvedBreachEmails () {
|
|||
const subscribers = await DB.getSubscribersWithUnresolvedBreaches()
|
||||
|
||||
subscribers.forEach(async subscriber => {
|
||||
const supportedLocales = [subscriber.signup_language, 'en'].filter(Boolean) // filter potential nullish signup_language
|
||||
const supportedLocales = [subscriber.signup_language, 'en'].filter(Boolean) // filter potential nullish signup_language, fallback to en
|
||||
const subject = LocaleUtils.fluentFormat(supportedLocales, 'email-unresolved-heading')
|
||||
|
||||
await EmailUtils.sendEmail(subscriber.primary_email, subject, 'email-2022',
|
||||
|
|
Загрузка…
Ссылка в новой задаче