Jas list error notification only in prod
This commit is contained in:
+10
-8
@@ -18,6 +18,7 @@ from sendgrid.helpers.mail import (
|
||||
from django.template.loader import render_to_string
|
||||
from django.core.files.base import ContentFile
|
||||
from sikweb.settings import (
|
||||
DEPLOY_ENV,
|
||||
FRONTEND_URL,
|
||||
EMAIL_API_KEY,
|
||||
DEFAULT_EMAIL_FROM,
|
||||
@@ -144,14 +145,15 @@ def add_to_mailinglist(email: str):
|
||||
# Already in list, do nothing
|
||||
if err.status_code == 409:
|
||||
pass
|
||||
# Something went wrong, send notification to maintainer.
|
||||
else:
|
||||
logging.exception("Failed adding user to list")
|
||||
|
||||
# Send email notificcation to maintainer, only in prod
|
||||
if DEPLOY_ENV == "production":
|
||||
to = "ilari.ojakorpi@sahkoinsinoorikilta.fi"
|
||||
subject = "Web error: Failed adding to google groups"
|
||||
body = "Error code: {}\nError details: {}\nEmail that was not added: {}\n\nAdd user manually to jäsenet groups.".format(
|
||||
err.status_code, err.error_details, email
|
||||
)
|
||||
|
||||
to = "ilari.ojakorpi@sahkoinsinoorikilta.fi"
|
||||
subject = "Web error: Failed adding to google groups"
|
||||
body = "Error code: {}\nError details: {}\nEmail that was not added: {}\n\nAdd user manually to jäsenet groups.".format(
|
||||
err.status_code, err.error_details, email
|
||||
)
|
||||
|
||||
send_email(to, subject, body)
|
||||
send_email(to, subject, body)
|
||||
|
||||
Reference in New Issue
Block a user