Skip to content

Commit

Permalink
feat: added email to nofity FI user when MSME submits a document uplo…
Browse files Browse the repository at this point in the history
…ad request
  • Loading branch information
Lombardoh committed Jul 13, 2023
1 parent 23a2ff2 commit a71bf8b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/core/email_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
"OVERDUE_APPLICATION_FI": "credere-OverdueApplicationFI",
"OVERDUE_APPLICATION_OCP_ADMIN": "credere-OverdueApplicationOCPadmin",
"NEW_CONTRACT_SUBMISSION": "credere-NewContractSubmission",
"APPLICATION_UPDATE": "credere-ApplicationUpdate",
}
7 changes: 7 additions & 0 deletions app/core/user_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ def send_upload_contract_notifications(self, application):

return FI_message_id, SME_message_id

def send_upload_documents_notifications(self, email: str):
message_id = email_utility.send_upload_documents_notifications_to_FI(
self.ses,
email,
)
return message_id


cognito = boto3.client(
"cognito-idp",
Expand Down
12 changes: 12 additions & 0 deletions app/routers/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ async def email_sme(
)
async def complete_information_request(
payload: ApiSchema.ApplicationBase,
client: CognitoClient = Depends(get_cognito_client),
session: Session = Depends(get_db),
):
with transaction_session(session):
Expand All @@ -984,6 +985,17 @@ async def complete_information_request(
payload,
)

message_id = client.send_upload_documents_notifications(
application.lender.email_group
)

utils.create_message(
application,
core.ApplicationActionType.BORROWER_DOCUMENT_UPDATE,
session,
message_id,
)

return ApiSchema.ApplicationResponse(
application=application,
borrower=application.borrower,
Expand Down
19 changes: 19 additions & 0 deletions app/utils/email_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,3 +432,22 @@ def send_rejected_application_email_without_alternatives(ses, application):
TemplateData=json.dumps(data),
)
return response.get("MessageId")


def send_upload_documents_notifications_to_FI(ses, email: str):
# todo refactor required when this function receives the user language
images_base_url = get_images_base_url()
data = {
**generate_common_data(),
"LOGIN_IMAGE_LINK": images_base_url + "/logincompleteimage.png",
"LOGIN_URL": app_settings.frontend_url + "/login",
}

response = ses.send_templated_email(
Source=app_settings.email_sender_address,
# replace with email on production
Destination={"ToAddresses": [app_settings.test_mail_receiver]},
Template=templates["APPLICATION_UPDATE"],
TemplateData=json.dumps(data),
)
return response.get("MessageId")

0 comments on commit a71bf8b

Please sign in to comment.