From 99360655a037d65d0399d3286d50a24d9a51fdc2 Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Thu, 6 Jun 2024 08:57:49 -0700 Subject: [PATCH] 20087 - Mailer changes for suspension (#2851) * Mailer changes for suspension * lint fix * alphabetical * repoint at correct branch * point at branch --- auth-api/src/auth_api/utils/account_mailer.py | 3 ++- auth-api/src/auth_api/utils/enums.py | 7 +++++++ queue_services/account-mailer/requirements.txt | 2 +- .../email_processors/common_mailer.py | 6 ++++++ .../email_templates/account_suspended_email.html | 15 ++++++++++----- .../email_templates/account_unlocked_email.html | 6 +++--- .../src/account_mailer/resources/worker.py | 4 ++-- queue_services/auth-queue/requirements.txt | 2 +- .../auth-queue/src/auth_queue/resources/worker.py | 6 +++--- 9 files changed, 35 insertions(+), 16 deletions(-) diff --git a/auth-api/src/auth_api/utils/account_mailer.py b/auth-api/src/auth_api/utils/account_mailer.py index 7da1f0cf5d..5a5da373f9 100644 --- a/auth-api/src/auth_api/utils/account_mailer.py +++ b/auth-api/src/auth_api/utils/account_mailer.py @@ -18,9 +18,10 @@ from simple_cloudevent import SimpleCloudEvent from auth_api.services.gcp_queue import GcpQueue, queue +from auth_api.utils.enums import QueueSources -def publish_to_mailer(notification_type, data=None, source='sbc-auth-auth-api'): +def publish_to_mailer(notification_type, data=None, source=QueueSources.AUTH_API.value): """Publish to Account Mailer.""" cloud_event = SimpleCloudEvent( id=str(uuid.uuid4()), diff --git a/auth-api/src/auth_api/utils/enums.py b/auth-api/src/auth_api/utils/enums.py index bc6ac88e04..24fa91b551 100644 --- a/auth-api/src/auth_api/utils/enums.py +++ b/auth-api/src/auth_api/utils/enums.py @@ -367,3 +367,10 @@ class NRActionCodes(Enum): RENEW = 'REN' # restore with new name request RESTORATION = 'REST' # FUTURE: unused? delete? RESUBMIT = 'RESUBMIT' # FUTURE: unused? delete? + + +class QueueSources(Enum): + """Queue sources for PAY.""" + + AUTH_API = 'auth-api' + AUTH_QUEUE = 'auth-queue' diff --git a/queue_services/account-mailer/requirements.txt b/queue_services/account-mailer/requirements.txt index 684e3619eb..2605734be9 100644 --- a/queue_services/account-mailer/requirements.txt +++ b/queue_services/account-mailer/requirements.txt @@ -34,6 +34,6 @@ tornado==6.4 urllib3==2.2.1 zipp==3.19.0 -e git+https://github.com/bcgov/sbc-common-components.git#egg=sbc-common-components&subdirectory=python --e git+https://github.com/seeker25/sbc-auth.git@refactor_queues#egg=auth-api&subdirectory=auth-api +-e git+https://github.com/seeker25/sbc-auth.git@20087#egg=auth-api&subdirectory=auth-api -e git+https://github.com/seeker25/sbc-connect-common.git@small_tweaks#egg=gcp-queue&subdirectory=python/gcp-queue git+https://github.com/daxiom/simple-cloudevent.py.git diff --git a/queue_services/account-mailer/src/account_mailer/email_processors/common_mailer.py b/queue_services/account-mailer/src/account_mailer/email_processors/common_mailer.py index e794811309..3b446ce0cb 100644 --- a/queue_services/account-mailer/src/account_mailer/email_processors/common_mailer.py +++ b/queue_services/account-mailer/src/account_mailer/email_processors/common_mailer.py @@ -25,9 +25,13 @@ def process(org_id, recipients, template_name, subject, logo_url, **kwargs) -> d current_app.logger.debug('account notification: %s', org_id) account_name: str = None + account_name_with_branch: str = None if org_id: org: OrgModel = OrgModel.find_by_id(org_id) account_name = org.name + account_name_with_branch = org.name + if org.branch_name: + account_name_with_branch = f'{org.name} - {org.branch_name}' # fill in template filled_template = generate_template(current_app.config.get('TEMPLATE_PATH'), template_name) @@ -35,6 +39,8 @@ def process(org_id, recipients, template_name, subject, logo_url, **kwargs) -> d jnja_template = Template(filled_template, autoescape=True) jinja_kwargs = { 'account_name': account_name, + 'account_name_with_branch': account_name_with_branch, + 'account_number': org_id, 'url': get_login_url(), 'logo_url': logo_url, 'dashboard_url': get_dashboard_url(), diff --git a/queue_services/account-mailer/src/account_mailer/email_templates/account_suspended_email.html b/queue_services/account-mailer/src/account_mailer/email_templates/account_suspended_email.html index 22e7b4a3a2..3649b62b5e 100644 --- a/queue_services/account-mailer/src/account_mailer/email_templates/account_suspended_email.html +++ b/queue_services/account-mailer/src/account_mailer/email_templates/account_suspended_email.html @@ -1,9 +1,14 @@ -# Your BC Registries and Online Services account has been suspended. +# Account suspended for {{ account_number }} - {{ account_name_with_branch }} -The following account has been suspended due to a failed payment. - -{{ account_name }} +Your account has been suspended due to a failed or overdue payment(s). Log in to BC Registries and Online Services to reactivate your account. -[Log in]({{ url }}) \ No newline at end of file +[Log in]({{ url }}) + +**Business Registry** +BC Registries and Online Services +Toll Free: [1-877-526-1526](1-877-526-1526) +Victoria Office: [250-387-7848](250-387-7848) +Email: [BCRegistries@gov.bc.ca](BCRegistries@gov.bc.ca) + diff --git a/queue_services/account-mailer/src/account_mailer/email_templates/account_unlocked_email.html b/queue_services/account-mailer/src/account_mailer/email_templates/account_unlocked_email.html index 094e0132d4..81ec01e687 100644 --- a/queue_services/account-mailer/src/account_mailer/email_templates/account_unlocked_email.html +++ b/queue_services/account-mailer/src/account_mailer/email_templates/account_unlocked_email.html @@ -1,11 +1,11 @@ # Account Unlocked -Your account **{{ account_name }}** has been unlocked. Team members can now log in and access this account. +Your account **{{ account_name_with_branch }}** has been unlocked. Team members can now log in and access this account. Your receipt is attached to this email: **Business Registry** BC Registries and Online Services -Toll Free: [1-877-370-1033](1-877-370-1033) -Victoria Office: [250-370-1033](250-370-1033) +Toll Free: [1-877-526-1526](1-877-526-1526) +Victoria Office: [250-387-7848](250-387-7848) Email: [BCRegistries@gov.bc.ca](BCRegistries@gov.bc.ca) diff --git a/queue_services/account-mailer/src/account_mailer/resources/worker.py b/queue_services/account-mailer/src/account_mailer/resources/worker.py index 0a45ec599e..dc155154e8 100644 --- a/queue_services/account-mailer/src/account_mailer/resources/worker.py +++ b/queue_services/account-mailer/src/account_mailer/resources/worker.py @@ -126,7 +126,7 @@ def handle_eft_available_notification(message_type, email_msg): def handle_nsf_lock_unlock_account(message_type, email_msg): """Handle the NSF lock/unlock account message.""" if message_type == QueueMessageTypes.NSF_LOCK_ACCOUNT.value: - current_app.logger.debug('lock account message recieved:') + current_app.logger.debug('Lock account message received') template_name = TemplateType.NSF_LOCK_ACCOUNT_TEMPLATE_NAME.value org_id = email_msg.get('accountId') admin_coordinator_emails = get_member_emails(org_id, (ADMIN, COORDINATOR)) @@ -136,7 +136,7 @@ def handle_nsf_lock_unlock_account(message_type, email_msg): subject, logo_url=logo_url) process_email(email_dict) elif message_type == QueueMessageTypes.NSF_UNLOCK_ACCOUNT.value: - current_app.logger.debug('unlock account message received') + current_app.logger.debug('Unlock account message received') template_name = TemplateType.NSF_UNLOCK_ACCOUNT_TEMPLATE_NAME.value org_id = email_msg.get('accountId') admin_coordinator_emails = get_member_emails(org_id, (ADMIN, COORDINATOR)) diff --git a/queue_services/auth-queue/requirements.txt b/queue_services/auth-queue/requirements.txt index 51e2fd7792..fc24eaa8bc 100644 --- a/queue_services/auth-queue/requirements.txt +++ b/queue_services/auth-queue/requirements.txt @@ -47,6 +47,6 @@ tornado==6.4 urllib3==2.2.1 zipp==3.19.0 -e git+https://github.com/bcgov/sbc-common-components.git#egg=sbc-common-components&subdirectory=python --e git+https://github.com/seeker25/sbc-auth.git@refactor_queues#egg=auth-api&subdirectory=auth-api +-e git+https://github.com/seeker25/sbc-auth.git@20087#egg=auth-api&subdirectory=auth-api -e git+https://github.com/seeker25/sbc-connect-common.git@small_tweaks#egg=gcp-queue&subdirectory=python/gcp-queue git+https://github.com/daxiom/simple-cloudevent.py.git diff --git a/queue_services/auth-queue/src/auth_queue/resources/worker.py b/queue_services/auth-queue/src/auth_queue/resources/worker.py index 09012be863..8b7fb84dac 100644 --- a/queue_services/auth-queue/src/auth_queue/resources/worker.py +++ b/queue_services/auth-queue/src/auth_queue/resources/worker.py @@ -27,7 +27,7 @@ from auth_api.services.gcp_queue.gcp_auth import ensure_authorized_queue_user from auth_api.services.rest_service import RestService from auth_api.utils.account_mailer import publish_to_mailer -from auth_api.utils.enums import AccessType, ActivityAction, CorpType, OrgStatus +from auth_api.utils.enums import AccessType, ActivityAction, CorpType, OrgStatus, QueueSources from dateutil import parser from flask import Blueprint, current_app, request from sbc_common_components.utils.enums import QueueMessageTypes @@ -115,11 +115,11 @@ def process_pay_lock_unlock_event(event_message: SimpleCloudEvent): org.status_code = OrgStatus.NSF_SUSPENDED.value org.suspended_on = datetime.now() org.suspension_reason_code = queue_data.get('suspensionReasonCode', None) - publish_to_mailer(QueueMessageTypes.NSF_LOCK_ACCOUNT.value, data) + publish_to_mailer(QueueMessageTypes.NSF_LOCK_ACCOUNT.value, data, QueueSources.AUTH_QUEUE.value) elif message_type == QueueMessageTypes.NSF_UNLOCK_ACCOUNT.value: org.status_code = OrgStatus.ACTIVE.value org.suspension_reason_code = None - publish_to_mailer(QueueMessageTypes.NSF_UNLOCK_ACCOUNT.value, data) + publish_to_mailer(QueueMessageTypes.NSF_UNLOCK_ACCOUNT.value, data, QueueSources.AUTH_QUEUE.value) org.flush() db.session.commit()