Add check_custom_domain cronjob
This commit is contained in:
parent
a3d919db2e
commit
ffc59a6fad
|
@ -193,7 +193,7 @@ def send_cannot_create_domain_alias(user, alias, domain):
|
||||||
def send_email(to_email, subject, plaintext, html=None):
|
def send_email(to_email, subject, plaintext, html=None):
|
||||||
if NOT_SEND_EMAIL:
|
if NOT_SEND_EMAIL:
|
||||||
LOG.d(
|
LOG.d(
|
||||||
"send email with subject %s to %s, plaintext: %s",
|
"send email with subject '%s' to '%s', plaintext: %s",
|
||||||
subject,
|
subject,
|
||||||
to_email,
|
to_email,
|
||||||
plaintext,
|
plaintext,
|
||||||
|
|
42
cron.py
42
cron.py
|
@ -12,7 +12,10 @@ from app.config import (
|
||||||
ADMIN_EMAIL,
|
ADMIN_EMAIL,
|
||||||
MACAPP_APPLE_API_SECRET,
|
MACAPP_APPLE_API_SECRET,
|
||||||
APPLE_API_SECRET,
|
APPLE_API_SECRET,
|
||||||
|
EMAIL_SERVERS_WITH_PRIORITY,
|
||||||
|
URL,
|
||||||
)
|
)
|
||||||
|
from app.dns_utils import get_mx_domains
|
||||||
from app.email_utils import (
|
from app.email_utils import (
|
||||||
send_email,
|
send_email,
|
||||||
send_trial_end_soon_email,
|
send_trial_end_soon_email,
|
||||||
|
@ -314,6 +317,41 @@ def sanity_check():
|
||||||
LOG.d("Finish sanity check")
|
LOG.d("Finish sanity check")
|
||||||
|
|
||||||
|
|
||||||
|
def check_custom_domain():
|
||||||
|
LOG.d("Check verified domain for DNS issues")
|
||||||
|
|
||||||
|
for custom_domain in CustomDomain.query.filter(CustomDomain.verified == True):
|
||||||
|
mx_domains = get_mx_domains(custom_domain.domain)
|
||||||
|
|
||||||
|
if sorted(mx_domains) != sorted(EMAIL_SERVERS_WITH_PRIORITY):
|
||||||
|
user = custom_domain.user
|
||||||
|
LOG.exception(
|
||||||
|
"The MX record is not correctly set for %s %s %s",
|
||||||
|
custom_domain,
|
||||||
|
user,
|
||||||
|
mx_domains,
|
||||||
|
)
|
||||||
|
|
||||||
|
domain_dns_url = f"{URL}/dashboard/domains/{custom_domain.id}/dns"
|
||||||
|
|
||||||
|
send_email(
|
||||||
|
user.email,
|
||||||
|
f"Please update {custom_domain.domain} DNS on SimpleLogin",
|
||||||
|
render(
|
||||||
|
"transactional/custom-domain-dns-issue.txt",
|
||||||
|
custom_domain=custom_domain,
|
||||||
|
name=user.name or "",
|
||||||
|
domain_dns_url=domain_dns_url,
|
||||||
|
),
|
||||||
|
render(
|
||||||
|
"transactional/custom-domain-dns-issue.html",
|
||||||
|
custom_domain=custom_domain,
|
||||||
|
name=user.name or "",
|
||||||
|
domain_dns_url=domain_dns_url,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def delete_old_monitoring():
|
def delete_old_monitoring():
|
||||||
"""
|
"""
|
||||||
Delete old monitoring records
|
Delete old monitoring records
|
||||||
|
@ -341,6 +379,7 @@ if __name__ == "__main__":
|
||||||
"poll_apple_subscription",
|
"poll_apple_subscription",
|
||||||
"sanity_check",
|
"sanity_check",
|
||||||
"delete_old_monitoring",
|
"delete_old_monitoring",
|
||||||
|
"check_custom_domain",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -372,3 +411,6 @@ if __name__ == "__main__":
|
||||||
elif args.job == "delete_old_monitoring":
|
elif args.job == "delete_old_monitoring":
|
||||||
LOG.d("Delete old monitoring records")
|
LOG.d("Delete old monitoring records")
|
||||||
delete_old_monitoring()
|
delete_old_monitoring()
|
||||||
|
elif args.job == "check_custom_domain":
|
||||||
|
LOG.d("Check custom domain")
|
||||||
|
check_custom_domain()
|
||||||
|
|
|
@ -47,3 +47,8 @@ jobs:
|
||||||
schedule: "0 14 * * *"
|
schedule: "0 14 * * *"
|
||||||
captureStderr: true
|
captureStderr: true
|
||||||
|
|
||||||
|
- name: SimpleLogin Custom Domain check
|
||||||
|
command: python /code/cron.py -j check_custom_domain
|
||||||
|
shell: /bin/bash
|
||||||
|
schedule: "0 15 * * *"
|
||||||
|
captureStderr: true
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{{ render_text("Hi " + name) }}
|
||||||
|
|
||||||
|
{% call text() %}
|
||||||
|
We have detected that your domain <b>{{ custom_domain.domain }}</b> does not have the DNS set up correctly.
|
||||||
|
{% endcall %}
|
||||||
|
|
||||||
|
{% call text() %}
|
||||||
|
Please make sure to set up your domain following the instructions on your domain DNS page at
|
||||||
|
<a href="{{ domain_dns_url }}">{{ custom_domain.domain }} DNS</a>.
|
||||||
|
{% endcall %}
|
||||||
|
|
||||||
|
{% call text() %}
|
||||||
|
Feel free reply to this email if you have any question. <br>
|
||||||
|
Best, <br>
|
||||||
|
SimpleLogin team.
|
||||||
|
{% endcall %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
Hi {{name}}
|
||||||
|
|
||||||
|
We have detected that your domain {{ custom_domain.domain }} does not have the DNS set up correctly.
|
||||||
|
|
||||||
|
Please make sure to set up your domain following the instructions on your domain DNS page at:
|
||||||
|
{{ domain_dns_url }}
|
||||||
|
|
||||||
|
Feel free reply to this email if you have any question.
|
||||||
|
|
||||||
|
Best,
|
||||||
|
SimpleLogin team.
|
Loading…
Reference in New Issue