Files
overleaf-cep/services/web/app/src/Features/Email/EmailOptionsHelper.js
Timothée Alby 0703c6d21d Merge pull request #7142 from overleaf/ii-6756-gmail-flags-emails-as-dangerous
Change security email title

GitOrigin-RevId: d33c9d7998ada059dac61ba0d13eefedd66237fc
2022-03-24 09:03:38 +00:00

30 lines
921 B
JavaScript

function _getIndefiniteArticle(providerName) {
const vowels = ['a', 'e', 'i', 'o', 'u']
return vowels.includes(providerName.charAt(0).toLowerCase()) ? 'an' : 'a'
}
function _actionBuilder(providerName, action, accountLinked) {
if (providerName.toLowerCase() !== 'google') {
return `${providerName} account ${action}`
}
return accountLinked ? `New account ${action}` : `Account ${action}`
}
function linkOrUnlink(accountLinked, providerName, email) {
const action = accountLinked ? 'linked' : 'no longer linked'
const actionDescribed = accountLinked ? 'was linked to' : 'was unlinked from'
const indefiniteArticle = _getIndefiniteArticle(providerName)
return {
to: email,
action: _actionBuilder(providerName, action, accountLinked),
actionDescribed: `${indefiniteArticle} ${providerName} account ${actionDescribed} your account ${email}`,
}
}
module.exports = {
linkOrUnlink,
}