Skip to content

Commit

Permalink
♻️ refactor: Updated checkemail-v2 route to display count and trim de…
Browse files Browse the repository at this point in the history
…scription
  • Loading branch information
DevaOnBreaches committed Jan 12, 2024
1 parent b0de7e0 commit dd5ef06
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1787,6 +1787,7 @@ def search_email_v2(email):
# Proceed with email validation and breach data retrieval
email = email.lower()
exposed_breaches = {"breaches": []}
breach_count = 0

if not email or not validate_email(email):
return make_response(jsonify({"error": "Invalid or not found email"}), 404)
Expand All @@ -1813,12 +1814,15 @@ def search_email_v2(email):
breach_info = {
"breach_id": breach_id,
"date_of_breach": formatted_date,
"description_of_exposure": breach_record.get("xposure_desc"),
}
exposed_breaches["breaches"].append(breach_info)
breach_count += 1
exposed_breaches["breach_count"] = breach_count
return jsonify(exposed_breaches)
else:
return make_response(jsonify({"error": "No breaches found"}), 404)
return make_response(
jsonify({"error": "No breaches found", "breach_count": 0}), 404
)

except Exception as exception_details:
log_except(request.url, exception_details)
Expand Down

0 comments on commit dd5ef06

Please sign in to comment.