Skip to content

Commit

Permalink
fix: added trailing period for gandi (closes #197), fixed bounce repo…
Browse files Browse the repository at this point in the history
…rt, sync locales
  • Loading branch information
titanism committed Sep 13, 2023
1 parent 6c051dd commit b01d305
Show file tree
Hide file tree
Showing 30 changed files with 281 additions and 206 deletions.
10 changes: 8 additions & 2 deletions app/views/guides/provider.pug
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ block body
td.align-middle: strong.px-2 MX
td.align-middle: code.text-themed 10
td.align-middle.text-left.py-3
code#copy-mx1.d-block.text-themed.text-nowrap mx1.forwardemail.net
code#copy-mx1.d-block.text-themed.text-nowrap
| mx1.forwardemail.net
if provider && provider.trailingPeriod
= '.'
if !isBot(ctx.get("User-Agent"))
button.btn.btn-dark.btn-sm.text-nowrap.mt-1(
type="button",
Expand Down Expand Up @@ -262,7 +265,10 @@ block body
td.align-middle: strong.px-2 MX
td.align-middle: code.text-themed 10
td.align-middle.text-left.py-3
code#copy-mx2.d-block.text-themed.text-nowrap mx2.forwardemail.net
code#copy-mx2.d-block.text-themed.text-nowrap
| mx2.forwardemail.net
if provider && provider.trailingPeriod
= '.'
if !isBot(ctx.get("User-Agent"))
button.btn.btn-dark.btn-sm.text-nowrap.mt-1(
type="button",
Expand Down
2 changes: 2 additions & 0 deletions app/views/my-account/domains/verify-smtp.pug
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ block body
= "forwardemail.net"
else
= config.webHost
if provider && provider.trailingPeriod
= '.'
if !domain.has_return_path_record
button.btn.btn-dark.btn-sm.text-nowrap.mt-1(
type="button",
Expand Down
20 changes: 15 additions & 5 deletions config/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ function prefixHTMLPathBasedAnchors(html, baseURI) {
// NOTE: we might want to sort FAQ or pre-select or highlight/bump
// NOTE: anyone not using these providers we can flag for review
//
// 0 - slug
// 1 - name
// 2 - url
// 3 - gif
// 4 - host
// 5 - video
// 6 - trailing period (e.g. Gandi) <https://github.com/forwardemail/forwardemail.net/issues/197>
//
const NS_PROVIDERS = {
awsdns: [
'amazon-route-53',
Expand Down Expand Up @@ -117,7 +125,9 @@ const NS_PROVIDERS = {
'Gandi.net',
'https://id.gandi.net/login',
'gandi',
''
'',
'',
true
],
'googledomains.com': [
'google-domains',
Expand Down Expand Up @@ -326,9 +336,9 @@ function nsProviderLookup(domain) {

for (const [i, NS_PROVIDER_REGEX] of NS_PROVIDER_REGEXES.entries()) {
if (domain.ns.some((r) => NS_PROVIDER_REGEX.test(r))) {
const [slug, name, url, gif, host, video] =
const [slug, name, url, gif, host, video, trailingPeriod] =
NS_PROVIDERS[NS_PROVIDER_KEYS[i]];
provider = { slug, name, url, gif, host, video };
provider = { slug, name, url, gif, host, video, trailingPeriod };
break;
}
}
Expand All @@ -338,8 +348,8 @@ function nsProviderLookup(domain) {

let nsProviders = [];
for (const key of _.sortBy(NS_PROVIDER_KEYS, (key) => NS_PROVIDERS[key].name)) {
const [slug, name, url, gif, host, video] = NS_PROVIDERS[key];
nsProviders.push({ slug, name, url, gif, host, video });
const [slug, name, url, gif, host, video, trailingPeriod] = NS_PROVIDERS[key];
nsProviders.push({ slug, name, url, gif, host, video, trailingPeriod });
}

nsProviders = _.sortBy(
Expand Down
33 changes: 17 additions & 16 deletions jobs/bounce-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function makeDelimitedString(arr) {
makeDelimitedString([
'ID',
'Date',
'Level',
'Bounce Category',
'Bounce Action',
'Truth Source',
Expand Down Expand Up @@ -95,24 +96,24 @@ function makeDelimitedString(arr) {
created_at: {
$gte: dayjs(now).subtract(4, 'hour').toDate(),
$lte: now
},
bounce_category: { $ne: 'none' }
}
})
.sort({ created_at: 1, bounce_category: 1 })
.sort({ created_at: 1 })
.cursor()
.addCursorFlag('noCursorTimeout', true)) {
if (typeof log?.err?.bounceInfo?.category !== 'string') continue;
// add new row to spreadsheet
csv.push(
makeDelimitedString([
// ID
log.id,
// Date
dayjs(log.created_at).toISOString(),
// Level
log?.meta?.level,
// Bounce Category
log.err.bounceInfo.category,
log.bounce_category || 'none',
// Bounce Action
log.err.bounceInfo.action,
log?.err?.bounceInfo?.action || 'none',
// Truth Source
log?.err?.truthSource && log?.err?.truthSource
? log.err.truthSource
Expand Down Expand Up @@ -184,14 +185,14 @@ function makeDelimitedString(arr) {
])
);

if (!Number.isFinite(categories[log.err.bounceInfo.category]))
categories[log.err.bounceInfo.category] = 0;
if (!Number.isFinite(categories[log.bounce_category]))
categories[log.bounce_category] = 0;

// generic category counter
categories[log.err.bounceInfo.category]++;
categories[log.bounce_category]++;

// truth source blocklist category counter
if (log.err.bounceInfo.category === 'blocklist' && log?.err?.truthSource)
if (log.bounce_category === 'blocklist' && log?.err?.truthSource)
set.add(log.err.truthSource);
}

Expand All @@ -206,7 +207,7 @@ function makeDelimitedString(arr) {
}

const message = [
`<p>Bounces from ${dayjs(now)
`<p>Logs from ${dayjs(now)
.subtract(4, 'hour')
.format('M/D/YY h:mm A')} to ${dayjs(now).format(
'M/D/YY h:mm A z'
Expand All @@ -226,12 +227,12 @@ function makeDelimitedString(arr) {
template: 'alert',
message: {
to: config.email.message.from,
subject: `(${csv.length - 1}) Bounces for ${dayjs(now).format(
'M/D/YY h:mm A z'
)} (${set.size} trusted hosts blocked)`,
subject: `(${csv.length - 1}) Email Deliverability Logs for ${dayjs(
now
).format('M/D/YY h:mm A z')} (${set.size} trusted hosts blocked)`,
attachments: [
{
filename: `bounce-report-${dayjs(now).format(
filename: `email-deliverability-logs-${dayjs(now).format(
'YYYY-MM-DD-h-mm-A-z'
)}.csv`.toLowerCase(),
content: csv.join('\n')
Expand All @@ -249,7 +250,7 @@ function makeDelimitedString(arr) {
template: 'alert',
message: {
to: config.email.message.from,
subject: 'Bounce Report Issue'
subject: 'Email Deliverability Report Issue'
},
locals: {
message: `<pre><code>${JSON.stringify(
Expand Down
6 changes: 6 additions & 0 deletions jobs/sync-paid-alias-allowlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ graceful.listen();
domain.name,
alias.recipients.length
);
// add alias.name @ domain.name
if (
!alias.name.startsWith('/') &&
isEmail(`${alias.name}@${domain.name}`)
)
set.add(`${alias.name}@${domain.name}`);
for (const recipient of alias.recipients) {
if (isFQDN(recipient)) {
const domain = recipient.toLowerCase();
Expand Down
Loading

0 comments on commit b01d305

Please sign in to comment.