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

Tweaks for send_email #1786

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 4 additions & 3 deletions pay-api/src/pay_api/services/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

"""This manages all of the authorization service."""
import base64
from typing import List

from flask import abort, current_app, g

Expand Down Expand Up @@ -148,13 +149,13 @@ def get_account_admin_users(auth_account_id, **kwargs):
).json()


def get_emails_with_keycloak_role(role: str) -> str:
def get_emails_with_keycloak_role(role: str) -> List[str]:
"""Retrieve emails with the specified keycloak role."""
users = get_users_with_keycloak_role(role)
# Purpose of this is so our TEST users don't get hammered with emails, also our tester can easily switch this on.
if flags.is_on("override-eft-refund-emails", default=False):
return flags.value("override-eft-refund-emails")
return ",".join([user["email"] for user in users])
return flags.value("override-eft-refund-emails").split(",")
return [user["email"] for user in users]


def get_users_with_keycloak_role(role: str) -> dict:
Expand Down
2 changes: 1 addition & 1 deletion pay-api/src/pay_api/services/eft_refund.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def update_shortname_refund(refund_id: int, data: EFTShortNameRefundPatchRequest
staff_body = content.render_body()
expense_authority_recipients = get_emails_with_keycloak_role(Role.EFT_REFUND_APPROVER.value)
send_email(expense_authority_recipients, subject, staff_body)
client_recipients = refund.refund_email
client_recipients = [refund.refund_email]
client_body = content.render_body(is_for_client=True)
send_email(client_recipients, subject, client_body)
case _:
Expand Down
2 changes: 1 addition & 1 deletion pay-api/src/pay_api/services/email_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from pay_api.utils.serializable import Serializable


def send_email(recipients: list, subject: str, body: str):
def send_email(recipients: list[str], subject: str, body: str):
"""Send the email notification."""
# Note if we send HTML in the body, we aren't sending through GCNotify, ideally we'd like to send through GCNotify.
token = get_service_account_token()
Expand Down
Loading