|
43 | 43 | DEFAULT_USER_GROUP_LIMIT, |
44 | 44 | group_invite_link_from_env, |
45 | 45 | TEMPLATE_ID_BUGOUT_WELCOME_EMAIL, |
| 46 | + TEMPLATE_ID_MOONSTREAM_WELCOME_EMAIL, |
| 47 | + MOONSTREAM_APPLICATION_ID, |
46 | 48 | ) |
47 | 49 |
|
48 | 50 | logger = logging.getLogger(__name__) |
@@ -601,23 +603,34 @@ def change_password( |
601 | 603 | return user |
602 | 604 |
|
603 | 605 |
|
604 | | -def send_welcome_email(user: User) -> None: |
| 606 | +def send_welcome_email(user: User, application_id: Optional[uuid.UUID] = None) -> None: |
605 | 607 | """ |
606 | 608 | Send welcome email to each new user. |
607 | 609 | """ |
608 | 610 | user_id = str(user.id) |
609 | 611 | if SENDGRID_API_KEY is None: |
610 | 612 | logger.error( |
611 | | - "Missed SENDGRID_API_KEY, message was not sent to user with id: {user_id}" |
| 613 | + f"Missed SENDGRID_API_KEY, message was not sent to user with id: {user_id}" |
612 | 614 | ) |
613 | 615 | return |
614 | 616 |
|
615 | | - logger.info(f"Sending welcome email for user with id={user_id}...") |
616 | 617 | message = Mail( |
617 | 618 | from_email=f"Sophia from Bugout <{BUGOUT_FROM_EMAIL}>", to_emails=user.email |
618 | 619 | ) |
619 | 620 | message.dynamic_template_data = {"username": user.username} |
620 | | - message.template_id = TEMPLATE_ID_BUGOUT_WELCOME_EMAIL |
| 621 | + |
| 622 | + if application_id is not None: |
| 623 | + if str(application_id) != MOONSTREAM_APPLICATION_ID: |
| 624 | + logger.error( |
| 625 | + f"Unhandled welcome email for application with id: {str(application_id)}" |
| 626 | + ) |
| 627 | + return |
| 628 | + else: |
| 629 | + message.template_id = TEMPLATE_ID_MOONSTREAM_WELCOME_EMAIL |
| 630 | + else: |
| 631 | + message.template_id = TEMPLATE_ID_BUGOUT_WELCOME_EMAIL |
| 632 | + |
| 633 | + logger.info(f"Sending welcome email for user with id={user_id}...") |
621 | 634 |
|
622 | 635 | try: |
623 | 636 | sg = SendGridAPIClient(SENDGRID_API_KEY) |
|
0 commit comments