Stabilize Lead Engine calendar logic (v1.4) and integrate GTM Architect, B2B Assistant, and Transcription Tool into Docker stack [30388f42]
This commit is contained in:
@@ -8,6 +8,10 @@ from threading import Thread, Lock
|
||||
import uvicorn
|
||||
from fastapi import FastAPI, Response, BackgroundTasks
|
||||
import msal
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from /app/.env
|
||||
load_dotenv(dotenv_path="/app/.env", override=True)
|
||||
|
||||
# --- Zeitzonen-Konfiguration ---
|
||||
TZ_BERLIN = ZoneInfo("Europe/Berlin")
|
||||
@@ -60,10 +64,15 @@ def check_calendar_availability():
|
||||
"availabilityViewInterval": 60 # Check availability in 1-hour blocks
|
||||
}
|
||||
|
||||
url = f"{GRAPH_API_ENDPOINT}/users/{TARGET_EMAIL}/calendarView?startDateTime={start_time.isoformat()}&endDateTime={end_time.isoformat()}&$top=5"
|
||||
url = f"{GRAPH_API_ENDPOINT}/users/{TARGET_EMAIL}/calendarView"
|
||||
params = {
|
||||
"startDateTime": start_time.isoformat(),
|
||||
"endDateTime": end_time.isoformat(),
|
||||
"$top": 5
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.get(url, headers=headers)
|
||||
response = requests.get(url, headers=headers, params=params)
|
||||
if response.status_code == 200:
|
||||
events = response.json().get("value", [])
|
||||
if not events:
|
||||
@@ -75,6 +84,12 @@ def check_calendar_availability():
|
||||
subject = event.get('subject', 'No Subject')
|
||||
start = event.get('start', {}).get('dateTime')
|
||||
if start:
|
||||
# Fix for 7-digit microseconds from Graph API (e.g. 2026-03-09T17:00:00.0000000)
|
||||
if "." in start:
|
||||
main_part, frac_part = start.split(".")
|
||||
# Truncate to 6 digits max or remove if empty
|
||||
start = f"{main_part}.{frac_part[:6]}"
|
||||
|
||||
dt_obj = datetime.fromisoformat(start.replace('Z', '+00:00')).astimezone(TZ_BERLIN)
|
||||
start_formatted = dt_obj.strftime('%A, %d.%m.%Y um %H:%M Uhr')
|
||||
else: start_formatted = "N/A"
|
||||
|
||||
Reference in New Issue
Block a user