Merge branch 'develop' into django-v4
This commit is contained in:
+13
-2
@@ -25,7 +25,7 @@ from sikweb.settings import (
|
||||
DEFAULT_EMAIL_FROM_ADDR,
|
||||
ENABLE_AUTOMATIC_EMAILS,
|
||||
GROUP_KEY,
|
||||
GOOGLE_SERVICE_ACCOUNT,
|
||||
GOOGLE_CREDS,
|
||||
)
|
||||
from datetime import timedelta
|
||||
|
||||
@@ -136,7 +136,7 @@ def add_to_mailinglist(email: str):
|
||||
# create credentials, with subject is used to impersonate admin account
|
||||
# jas_manager has groups editor rights in google admin
|
||||
credentials = service_account.Credentials.from_service_account_info(
|
||||
info=GOOGLE_SERVICE_ACCOUNT, scopes=SCOPES
|
||||
info=GOOGLE_CREDS, scopes=SCOPES
|
||||
).with_subject("jas_manager@sahkoinsinoorikilta.fi")
|
||||
|
||||
service = build("admin", "directory_v1", credentials=credentials)
|
||||
@@ -157,3 +157,14 @@ def add_to_mailinglist(email: str):
|
||||
)
|
||||
|
||||
send_email(to, subject, body)
|
||||
except ValueError as err:
|
||||
logging.exception("Formatting of google credentials is incorrect")
|
||||
|
||||
if DEPLOY_ENV == "production":
|
||||
to = "ilari.ojakorpi@sahkoinsinoorikilta.fi"
|
||||
subject = "Web error: Failed adding to google groups"
|
||||
body = "Google credential formatted incorretly\nEmail that was not added: {}\n\nAdd user manually to jäsenet groups.".format(
|
||||
email
|
||||
)
|
||||
|
||||
send_email(to, subject, body)
|
||||
|
||||
Reference in New Issue
Block a user