rairo commited on
Commit
d6e218c
·
verified ·
1 Parent(s): f6f6a28

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -5
main.py CHANGED
@@ -17,6 +17,14 @@ import random
17
  from datetime import datetime as dt_class, timezone
18
  from zoneinfo import ZoneInfo
19
  import pandas as pd
 
 
 
 
 
 
 
 
20
 
21
  # === Logging Configuration ===
22
  if not os.path.exists('logs'):
@@ -37,10 +45,7 @@ root_logger.addHandler(file_handler)
37
  root_logger.addHandler(console_handler)
38
 
39
  # === ENV Config & Admin Setup ===
40
- # For authenticating API requests. This should match the users' actual login emails.
41
  ADMIN_EMAILS = ["rairorr@gmail.com", "nharingosheperd@gmail.com"]
42
-
43
- # NEW: For sending email notifications. This list works around the Resend bug.
44
  SEND_TO_EMAILS = ["rairorr@gmail.com", "nharingosheperd+guard@gmail.com"]
45
 
46
  RESEND_API_KEY = os.getenv("RESEND_API_KEY")
@@ -98,12 +103,11 @@ def send_rotation_notification(job_id, shift_record):
98
  job_name = job_data.get("name", "Unknown Job")
99
  shift_number = shift_record.get("shift_number", "Unknown")
100
 
101
- # --- TIMEZONE CONVERSION ---
102
  human_readable_time = 'Unknown'
103
  try:
104
  assigned_time_iso = shift_record.get('assigned_at', '')
105
  utc_time = dt_class.fromisoformat(assigned_time_iso)
106
- cat_tz = ZoneInfo("Africa/Harare") # CAT is UTC+2
107
  cat_time = utc_time.astimezone(cat_tz)
108
  human_readable_time = cat_time.strftime("%B %d, %Y at %I:%M %p %Z")
109
  except (ValueError, TypeError) as e:
 
17
  from datetime import datetime as dt_class, timezone
18
  from zoneinfo import ZoneInfo
19
  import pandas as pd
20
+ import certifi # <-- ADDED IMPORT
21
+ from resend import request as resend_request # <-- ADDED IMPORT
22
+
23
+ # === SSL CERTIFICATE FIX ===
24
+ # Force the Resend library's underlying requests to use a modern certificate bundle.
25
+ # This is the secure way to fix "CERTIFICATE_VERIFY_FAILED" errors in environments
26
+ # with outdated root certificates (like some container platforms).
27
+ resend_request.Requests.set_default_verify(certifi.where())
28
 
29
  # === Logging Configuration ===
30
  if not os.path.exists('logs'):
 
45
  root_logger.addHandler(console_handler)
46
 
47
  # === ENV Config & Admin Setup ===
 
48
  ADMIN_EMAILS = ["rairorr@gmail.com", "nharingosheperd@gmail.com"]
 
 
49
  SEND_TO_EMAILS = ["rairorr@gmail.com", "nharingosheperd+guard@gmail.com"]
50
 
51
  RESEND_API_KEY = os.getenv("RESEND_API_KEY")
 
103
  job_name = job_data.get("name", "Unknown Job")
104
  shift_number = shift_record.get("shift_number", "Unknown")
105
 
 
106
  human_readable_time = 'Unknown'
107
  try:
108
  assigned_time_iso = shift_record.get('assigned_at', '')
109
  utc_time = dt_class.fromisoformat(assigned_time_iso)
110
+ cat_tz = ZoneInfo("Africa/Harare")
111
  cat_time = utc_time.astimezone(cat_tz)
112
  human_readable_time = cat_time.strftime("%B %d, %Y at %I:%M %p %Z")
113
  except (ValueError, TypeError) as e: