Skip to content

Commit

Permalink
refactor a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
smcmurtry committed Jan 14, 2025
1 parent 71519b9 commit 3a5766d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 7 additions & 0 deletions app/clients/freshdesk.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ def email_freshdesk_ticket_freshdesk_down(self):
current_app.config["CONTACT_FORM_EMAIL_ADDRESS"], current_app.config["CONTACT_FORM_DIRECT_EMAIL_TEMPLATE_ID"]
)

def email_freshdesk_ticket_sensitive_service(self):
email_address = current_app.config.get("SENSITIVE_SERVICE_EMAIL")
template_id = current_app.config.get("CONTACT_FORM_SENSITIVE_SERVICE_EMAIL_TEMPLATE_ID")
if not email_address:
current_app.logger.error("Sensitive service email address not set")
self.email_freshdesk_ticket(email_address, template_id)

def email_freshdesk_ticket(self, email_address, template_id) -> None:
content = self._generate_ticket()
try:
Expand Down
9 changes: 2 additions & 7 deletions app/user/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,13 +491,8 @@ def send_contact_request(user_id):

if any(service_id in user_service_ids for service_id in sensitive_service_ids):
# Send to secure email instead of Freshdesk
email_address = current_app.config.get("SENSITIVE_SERVICE_EMAIL")
template_id = current_app.config.get("CONTACT_FORM_SENSITIVE_SERVICE_EMAIL_TEMPLATE_ID")
if not email_address:
current_app.logger.error("Sensitive service email address not set")
return jsonify({}), 500
status_code = Freshdesk(contact).email_freshdesk_ticket(email_address, template_id)
return jsonify({"status_code": status_code}), 204
Freshdesk(contact).email_freshdesk_ticket_sensitive_service()
return 201

status_code = Freshdesk(contact).send_ticket()
return jsonify({"status_code": status_code}), 204
Expand Down

0 comments on commit 3a5766d

Please sign in to comment.