diff --git a/hc/accounts/views.py b/hc/accounts/views.py index 501973cf..cee590ba 100644 --- a/hc/accounts/views.py +++ b/hc/accounts/views.py @@ -51,7 +51,7 @@ def login(request): login_link = settings.SITE_ROOT + login_link body = "login link: %s" % login_link - send_mail('Log In', body, 'cuu508@gmail.com', [email], + send_mail('Log In', body, settings.DEFAULT_FROM_EMAIL, [email], fail_silently=False) return redirect("hc-login-link-sent") diff --git a/hc/api/management/commands/sendalerts.py b/hc/api/management/commands/sendalerts.py index f27f00bf..bb6f75cb 100644 --- a/hc/api/management/commands/sendalerts.py +++ b/hc/api/management/commands/sendalerts.py @@ -18,28 +18,38 @@ class Command(BaseCommand): def handle(self, *args, **options): + ticks = 0 while True: # Gone down? query = Check.objects query = query.filter(alert_after__lt=timezone.now()) + query = query.filter(user__isnull=False) query = query.filter(status="up") for check in query: check.status = "down" - check.save() _log("\nSending email about going down for %s\n" % check.code) send_status_notification(check) + ticks = 0 + + # Save status after the notification is sent + check.save() # Gone up? query = Check.objects query = query.filter(alert_after__gt=timezone.now()) + query = query.filter(user__isnull=False) query = query.filter(status="down") for check in query: check.status = "up" - check.save() _log("\nSending email about going up for %s\n" % check.code) send_status_notification(check) + ticks = 0 + + # Save status after the notification is sent + check.save() time.sleep(1) - _log(".") + ticks = (ticks + 1) % 80 + _log("." + ("\n" if ticks == 0 else "")) diff --git a/hc/lib/emails.py b/hc/lib/emails.py index ecd2fbcf..70d9792e 100644 --- a/hc/lib/emails.py +++ b/hc/lib/emails.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.core.mail import send_mail @@ -11,5 +12,5 @@ def send_status_notification(check): else: raise NotImplemented("Unexpected status: %s" % check.status) - send_mail(subject, body, 'cuu508@gmail.com', [check.user.email], + send_mail(subject, body, settings.DEFAULT_FROM_EMAIL, [check.user.email], fail_silently=False) diff --git a/hc/settings.py b/hc/settings.py index 7db3484e..9331756f 100644 --- a/hc/settings.py +++ b/hc/settings.py @@ -19,6 +19,7 @@ HOST = "localhost" SECRET_KEY = "---" DEBUG = True ALLOWED_HOSTS = [] +DEFAULT_FROM_EMAIL = 'healthchecks@example.org' INSTALLED_APPS = ( @@ -95,8 +96,8 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static-collected') EMAIL_BACKEND = 'django_ses_backend.SESBackend' AWS_SES_ACCESS_KEY_ID = "---" AWS_SES_SECRET_ACCESS_KEY = "---" -AWS_SES_REGION_NAME = 'eu-west-1' -AWS_SES_REGION_ENDPOINT = 'email.eu-west-1.amazonaws.com' +AWS_SES_REGION_NAME = 'us-east-1' +AWS_SES_REGION_ENDPOINT = 'email.us-east-1.amazonaws.com' try: