From fd2775fb40b09d0779d8c4ccf47e8a098e0c1ac8 Mon Sep 17 00:00:00 2001 From: Greg V Date: Mon, 29 Jul 2024 21:16:07 -0700 Subject: [PATCH] Small update to also record when welcome email is sent for future use --- api/messages/messages_service.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/messages/messages_service.py b/api/messages/messages_service.py index 808586d..45f7ada 100644 --- a/api/messages/messages_service.py +++ b/api/messages/messages_service.py @@ -844,7 +844,13 @@ async def save_lead(json): slack_message = f"New lead! Name:`{json['name']}` Email:`{json['email']}`" send_slack(slack_message, "ohack-dev-leads") - send_welcome_email( json["name"], json["email"] ) + success_send_email = send_welcome_email( json["name"], json["email"] ) + if success_send_email: + logger.info(f"Sent welcome email to {json['email']}") + # Update db to add when email was sent + collection.document(insert_res[1].id).update({ + "welcome_email_sent": datetime.now().isoformat() + }) return True # Create an event loop and run the save_lead function asynchronously @@ -926,6 +932,7 @@ def send_welcome_email(name, email): email = resend.Emails.SendParams(params) resend.Emails.send(email) print(email) + return True @cached(cache=TTLCache(maxsize=100, ttl=32600), key=lambda news_limit, news_id: f"{news_limit}-{news_id}")