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

Updated code to set header on email subject based on desired logic #39

Merged
merged 4 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 8 additions & 1 deletion src/regtech_mail_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,14 @@ async def send_email(request: Request):
sender_addr = request.user.email
sender_name = request.user.name if request.user.name else ""
type = request.headers["case-type"]
subject = f"[DEV BETA] SBL User Request for {type}"

header = "[BETA]"
if "cfpb" in sender_addr.lower().split("@")[-1]:
header = "[CFPB BETA]"
if settings.environment:
header = f"[{settings.environment}]"

subject = f"{header} SBL User Request for {type}"

form_data = await request.form()

Expand Down
1 change: 1 addition & 0 deletions src/regtech_mail_api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class EmailMailerType(str, Enum):


class EmailApiSettings(BaseSettings):
environment: str = ""
email_mailer: EmailMailerType = EmailMailerType.SMTP
smtp_host: str | None = None
smtp_port: int = 0
Expand Down
4 changes: 2 additions & 2 deletions tests/test_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_send_no_profile(
):
email_json = {
"email": {
"subject": "[DEV BETA] SBL User Request for Institution Profile Change",
"subject": "[CFPB BETA] SBL User Request for Institution Profile Change",
"body": "Contact Email: [email protected]\nContact Name: \n\nlei: 1234567890ABCDEFGHIJ\ninstitution_name_1: Fintech 1\ntin_1: 12-3456789\nrssd_1: 1234567",
"from_addr": "[email protected]",
"to": ["[email protected]"],
Expand Down Expand Up @@ -87,7 +87,7 @@ def test_send(
):
email_json = {
"email": {
"subject": "[DEV BETA] SBL User Request for Institution Profile Change",
"subject": "[CFPB BETA] SBL User Request for Institution Profile Change",
"body": "Contact Email: [email protected]\nContact Name: Test User\n\nlei: 1234567890ABCDEFGHIJ\ninstitution_name_1: Fintech 1\ntin_1: 12-3456789\nrssd_1: 1234567",
"from_addr": "[email protected]",
"to": ["[email protected]"],
Expand Down
Loading