Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add enable newsletter button in admin view #279

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions app/controllers/web/admin/domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ async function update(ctx) {
const hadSMTPAccess = Boolean(domain.has_smtp);
if (isSANB(body.has_smtp)) domain.has_smtp = boolean(body.has_smtp);

// has_newsletter
const hadNewsletterAccess = Boolean(domain.has_newsletter);
if (isSANB(body.has_newsletter)) {
if (!hadSMTPAccess) {
throw Boom.forbidden(ctx.translateError('DOMAIN_REQUIRES_SMTP_ACCESS'));
}

domain.has_smtp = boolean(body.has_newsletter);
}

// smtp_suspended_sent_at
const hadSMTPSuspension = _.isDate(domain.smtp_suspended_sent_at);
if (isSANB(body.smtp_suspended_sent_at)) {
Expand Down Expand Up @@ -219,6 +229,50 @@ async function update(ctx) {
});
}

if (!hadNewsletterAccess && domain.has_newsletter) {
const subject = i18n.translate(
'EMAIL_NEWSLETTER_ACCESS_ENABLED_SUBJECT',
obj.locale,
domain.name
);
const message = i18n.translate(
'EMAIL_NEWSLETTER_ACCESS_ENABLED_MESSAGE',
obj.locale,
domain.name,
`${config.urls.web}/${obj.locale}/my-account/domains/${domain.name}/verify-smtp`
);
await emailHelper({
template: 'alert',
message: {
to: obj.to,
bcc: config.email.message.from,
subject
},
locals: {
message,
locale: obj.locale
}
});
} else if (hadNewsletterAccess && !domain.has_newsletter) {
const subject = i18n.translate(
'EMAIL_NEWSLETTER_ACCESS_DISABLED',
obj.locale,
domain.name
);
await emailHelper({
template: 'alert',
message: {
to: obj.to,
bcc: config.email.message.from,
subject
},
locals: {
message: subject,
locale: obj.locale
}
});
}

ctx.flash('custom', {
title: ctx.request.t('Success'),
text: ctx.translate('REQUEST_OK'),
Expand Down
22 changes: 22 additions & 0 deletions app/views/admin/domains/_table.pug
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ include ../../_pagination
+sortHeader('has_txt_record', 'TXT', '#table-domains')
th(scope="col")
+sortHeader('has_smtp', 'SMTP Enabled', '#table-domains')
th(scope="col")
+sortHeader('has_newsletter', 'Newsletter Enabled', '#table-domains')
th(scope="col")
+sortHeader('smtp_suspended_sent_at', 'SMTP Suspended', '#table-domains')
th(scope="col")
Expand Down Expand Up @@ -82,6 +84,26 @@ include ../../_pagination
= "Disable SMTP"
else
= "Enable SMTP"
td.align-middle.text-center
form.ajax-form.confirm-prompt.d-inline-block(
action=l(`/admin/domains/${domain.id}`),
method="POST",
autocomplete=config.env === "test" ? "off" : randomstring()
)
input(type="hidden", name="_method", value="PUT")
input(
type="hidden",
name="has_newsletter",
value=(!domain.has_newsletter).toString()
)
button.btn.btn-sm(
type="submit",
class=domain.has_newsletter ? "btn-danger" : "btn-success"
)
if domain.has_newsletter
= "Disable Newsletter"
else
= "Enable Newsletter"
td.align-middle.text-center
form.ajax-form.confirm-prompt.d-inline-block(
action=l(`/admin/domains/${domain.id}`),
Expand Down
7 changes: 7 additions & 0 deletions config/phrases.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ module.exports = {
'<p class="text-center">Your domain <span class="notranslate">%s</span> was approved for outbound SMTP access.</p><p class="text-center mb-0"><a class="btn btn-lg btn-danger" href="%s">Complete Setup</a></p>',
EMAIL_SMTP_ACCESS_DISABLED:
'<p class="text-center text-danger">Your domain <span class="notranslate">%s</span> had its outbound SMTP access removed.</p>',
EMAIL_NEWSLETTER_ACCESS_ENABLED_SUBJECT:
'<span class="notranslate">%s</span> approved for NEWSLETTER access',
EMAIL_NEWSLETTER_ACCESS_ENABLED_MESSAGE:
'<p class="text-center">Your domain <span class="notranslate">%s</span> was approved for NEWSLETTER access.</p><p class="text-center mb-0"><a class="btn btn-lg btn-danger" href="%s">Complete Setup</a></p>',
EMAIL_NEWSLETTER_ACCESS_DISABLED:
'<p class="text-center text-danger">Your domain <span class="notranslate">%s</span> had its NEWSLETTER access removed.</p>',
EMAIL_SMTP_ACCESS_REQUIRED:
'Domain is not approved for outbound SMTP access, please <a class="font-weight-bold" href="/help">contact us</a>.',
ENVELOPE_FROM_MISSING:
Expand Down Expand Up @@ -344,6 +350,7 @@ module.exports = {
EXCEEDED_UNIQUE_COUNT:
'You have exceeded the maximum count of (<span class="notranslate">%s</span>) recipients per alias. Please <a class="font-weight-bold" href="/help">contact us</a> if you wish to have this limit increased. We review requests on a unique basis. Please provide us with information about your forwarding purposes if possible.',
DOMAIN_DOES_NOT_EXIST_ANYWHERE: 'Domain does not exist.',
DOMAIN_REQUIRES_SMTP_ACCESS: 'Domain requires SMTP access.',
INVITE_DOES_NOT_EXIST:
'Invite does not exist with your email address for this domain.',
DOMAIN_ALREADY_EXISTS: 'Domain already exists on your account.',
Expand Down
9 changes: 8 additions & 1 deletion locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -10253,5 +10253,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- ينطبق هذا فقط على SMTP الصادر ويرتبط بمعرف البريد الإلكتروني المخزن في حسابي → رسائل البريد الإلكتروني",
"Bank Transfer": "التحويل البنكي",
"Domestic Wire Transfer (Enterprise)": "التحويل البنكي المحلي (المؤسسي)",
"International Wire Transfer (Enterprise)": "التحويل البنكي الدولي (المؤسسات)"
"International Wire Transfer (Enterprise)": "التحويل البنكي الدولي (المؤسسات)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
9 changes: 8 additions & 1 deletion locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -10253,5 +10253,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- to platí pouze pro odchozí SMTP a souvisí s e-mailovým ID uloženým v Můj účet → E-maily",
"Bank Transfer": "Bankovní převod",
"Domestic Wire Transfer (Enterprise)": "Domácí bankovní převod (podnikové)",
"International Wire Transfer (Enterprise)": "Mezinárodní bankovní převod (podnik)"
"International Wire Transfer (Enterprise)": "Mezinárodní bankovní převod (podnik)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
9 changes: 8 additions & 1 deletion locales/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -7224,5 +7224,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- dette gælder kun for udgående SMTP og korrelerer med det e-mail-id, der er gemt i Min konto → E-mails",
"Bank Transfer": "Bankoverførsel",
"Domestic Wire Transfer (Enterprise)": "Indenlandsk bankoverførsel (virksomhed)",
"International Wire Transfer (Enterprise)": "International bankoverførsel (Enterprise)"
"International Wire Transfer (Enterprise)": "International bankoverførsel (Enterprise)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
9 changes: 8 additions & 1 deletion locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -9292,5 +9292,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- dies gilt nur für ausgehendes SMTP und korreliert mit der E-Mail-ID, die unter Mein Konto → E-Mails gespeichert ist",
"Bank Transfer": "Banküberweisung",
"Domestic Wire Transfer (Enterprise)": "Inlandsüberweisung (Unternehmen)",
"International Wire Transfer (Enterprise)": "Internationale elektronische Überweisung (Unternehmen)"
"International Wire Transfer (Enterprise)": "Internationale elektronische Überweisung (Unternehmen)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
9 changes: 8 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9984,5 +9984,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails",
"Bank Transfer": "Bank Transfer",
"Domestic Wire Transfer (Enterprise)": "Domestic Wire Transfer (Enterprise)",
"International Wire Transfer (Enterprise)": "International Wire Transfer (Enterprise)"
"International Wire Transfer (Enterprise)": "International Wire Transfer (Enterprise)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
9 changes: 8 additions & 1 deletion locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -10251,5 +10251,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- esto solo se aplica al SMTP saliente y se correlaciona con el ID de correo electrónico almacenado en Mi cuenta → Correos electrónicos",
"Bank Transfer": "Transferencia bancaria",
"Domestic Wire Transfer (Enterprise)": "Transferencia bancaria nacional (empresa)",
"International Wire Transfer (Enterprise)": "Transferencia bancaria internacional (empresa)"
"International Wire Transfer (Enterprise)": "Transferencia bancaria internacional (empresa)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
9 changes: 8 additions & 1 deletion locales/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -10100,5 +10100,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- tämä koskee vain lähtevää SMTP:tä ja korreloi sähköpostitunnukseen, joka on tallennettu kohtaan Oma tili → Sähköpostit",
"Bank Transfer": "Pankkisiirto",
"Domestic Wire Transfer (Enterprise)": "Kotimainen pankkisiirto (yritys)",
"International Wire Transfer (Enterprise)": "Kansainvälinen pankkisiirto (yritys)"
"International Wire Transfer (Enterprise)": "Kansainvälinen pankkisiirto (yritys)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
9 changes: 8 additions & 1 deletion locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -7776,5 +7776,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- ceci ne s'applique qu'au SMTP sortant et correspond à l'identifiant de messagerie stocké dans Mon compte → E-mails",
"Bank Transfer": "Virement bancaire",
"Domestic Wire Transfer (Enterprise)": "Virement bancaire national (entreprise)",
"International Wire Transfer (Enterprise)": "Virement bancaire international (entreprise)"
"International Wire Transfer (Enterprise)": "Virement bancaire international (entreprise)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
9 changes: 8 additions & 1 deletion locales/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -8272,5 +8272,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- זה ישים רק עבור SMTP יוצא ומתאם למזהה הדוא\"ל המאוחסן ב'חשבון שלי ← הודעות דוא\"ל",
"Bank Transfer": "העברה בנקאית",
"Domestic Wire Transfer (Enterprise)": "העברה בנקאית מקומית (ארגוני)",
"International Wire Transfer (Enterprise)": "העברה בנקאית בינלאומית (ארגוני)"
"International Wire Transfer (Enterprise)": "העברה בנקאית בינלאומית (ארגוני)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
9 changes: 8 additions & 1 deletion locales/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -10253,5 +10253,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- ez csak a kimenő SMTP-re vonatkozik, és a Saját fiók → E-mailek menüpontban tárolt e-mail azonosítóhoz kapcsolódik",
"Bank Transfer": "Banki átutalás",
"Domestic Wire Transfer (Enterprise)": "Belföldi banki átutalás (vállalati)",
"International Wire Transfer (Enterprise)": "Nemzetközi banki átutalás (vállalati)"
"International Wire Transfer (Enterprise)": "Nemzetközi banki átutalás (vállalati)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
9 changes: 8 additions & 1 deletion locales/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -10253,5 +10253,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- ini hanya berlaku untuk SMTP keluar dan berkorelasi dengan ID email yang disimpan di Akun Saya → Email",
"Bank Transfer": "Transfer Bank",
"Domestic Wire Transfer (Enterprise)": "Transfer Kawat Domestik (Perusahaan)",
"International Wire Transfer (Enterprise)": "Transfer Bank Internasional (Perusahaan)"
"International Wire Transfer (Enterprise)": "Transfer Bank Internasional (Perusahaan)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
9 changes: 8 additions & 1 deletion locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -10253,5 +10253,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- questo è applicabile solo per SMTP in uscita e si correla all'ID e-mail memorizzato in Il mio account → E-mail",
"Bank Transfer": "Bonifico bancario",
"Domestic Wire Transfer (Enterprise)": "Bonifico bancario nazionale (impresa)",
"International Wire Transfer (Enterprise)": "Bonifico bancario internazionale (aziendale)"
"International Wire Transfer (Enterprise)": "Bonifico bancario internazionale (aziendale)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
9 changes: 8 additions & 1 deletion locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -10253,5 +10253,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- これは送信SMTPにのみ適用され、マイアカウント→メールに保存されているメールIDと相関します。",
"Bank Transfer": "銀行振込",
"Domestic Wire Transfer (Enterprise)": "国内電信送金(企業)",
"International Wire Transfer (Enterprise)": "国際電信送金(エンタープライズ)"
"International Wire Transfer (Enterprise)": "国際電信送金(エンタープライズ)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
9 changes: 8 additions & 1 deletion locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -10253,5 +10253,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- 이것은 아웃바운드 SMTP에만 적용되며 내 계정 → 이메일에 저장된 이메일 ID와 상관 관계가 있습니다.",
"Bank Transfer": "은행 송금",
"Domestic Wire Transfer (Enterprise)": "국내 송금(기업)",
"International Wire Transfer (Enterprise)": "국제 송금(기업)"
"International Wire Transfer (Enterprise)": "국제 송금(기업)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
9 changes: 8 additions & 1 deletion locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -10253,5 +10253,12 @@
"- this is only applicable for outbound SMTP and correlates to the email ID stored in My Account → Emails": "- dit is alleen van toepassing op uitgaande SMTP en komt overeen met de e-mail-ID die is opgeslagen in Mijn account → E-mails",
"Bank Transfer": "Bankoverschrijving",
"Domestic Wire Transfer (Enterprise)": "Binnenlandse overschrijving (zakelijk)",
"International Wire Transfer (Enterprise)": "Internationale overschrijving (onderneming)"
"International Wire Transfer (Enterprise)": "Internationale overschrijving (onderneming)",
"Search for inquiries": "Search for inquiries",
"Search by email": "Search by email",
"Reply": "Reply",
"Search for domains": "Search for domains",
"Search by domain name (RegExp supported) or email": "Search by domain name (RegExp supported) or email",
"Newsletter Enabled": "Newsletter Enabled",
"Domain requires SMTP access.": "Domain requires SMTP access."
}
Loading
Loading