This commit is contained in:
Taylor Wilsdon
2026-02-06 10:59:46 -05:00
parent 0f80ce1a4d
commit 2df308c7f7
3 changed files with 1073 additions and 1065 deletions

View File

@@ -376,9 +376,9 @@ async def get_events(
if event_id:
logger.info(f"[get_events] Retrieving single event with ID: {event_id}")
event = await asyncio.to_thread(
lambda: service.events()
.get(calendarId=calendar_id, eventId=event_id)
.execute()
lambda: (
service.events().get(calendarId=calendar_id, eventId=event_id).execute()
)
)
items = [event]
else:
@@ -701,7 +701,8 @@ async def create_event(
if drive_service:
try:
file_metadata = await asyncio.to_thread(
lambda: drive_service.files()
lambda: (
drive_service.files()
.get(
fileId=file_id,
fields="mimeType,name",
@@ -709,6 +710,7 @@ async def create_event(
)
.execute()
)
)
mime_type = file_metadata.get("mimeType", mime_type)
filename = file_metadata.get("name")
if filename:
@@ -735,7 +737,8 @@ async def create_event(
if drive_service:
drive_service.close()
created_event = await asyncio.to_thread(
lambda: service.events()
lambda: (
service.events()
.insert(
calendarId=calendar_id,
body=event_body,
@@ -744,9 +747,11 @@ async def create_event(
)
.execute()
)
)
else:
created_event = await asyncio.to_thread(
lambda: service.events()
lambda: (
service.events()
.insert(
calendarId=calendar_id,
body=event_body,
@@ -754,6 +759,7 @@ async def create_event(
)
.execute()
)
)
link = created_event.get("htmlLink", "No link available")
confirmation_message = f"Successfully created event '{created_event.get('summary', summary)}' for {user_google_email}. Link: {link}"
@@ -976,9 +982,9 @@ async def modify_event(
# Get the existing event to preserve fields that aren't being updated
try:
existing_event = await asyncio.to_thread(
lambda: service.events()
.get(calendarId=calendar_id, eventId=event_id)
.execute()
lambda: (
service.events().get(calendarId=calendar_id, eventId=event_id).execute()
)
)
logger.info(
"[modify_event] Successfully retrieved existing event before update"
@@ -1035,7 +1041,8 @@ async def modify_event(
# Proceed with the update
updated_event = await asyncio.to_thread(
lambda: service.events()
lambda: (
service.events()
.update(
calendarId=calendar_id,
eventId=event_id,
@@ -1044,6 +1051,7 @@ async def modify_event(
)
.execute()
)
)
link = updated_event.get("htmlLink", "No link available")
confirmation_message = f"Successfully modified event '{updated_event.get('summary', summary)}' (ID: {event_id}) for {user_google_email}. Link: {link}"
@@ -1096,9 +1104,9 @@ async def delete_event(
# Try to get the event first to verify it exists
try:
await asyncio.to_thread(
lambda: service.events()
.get(calendarId=calendar_id, eventId=event_id)
.execute()
lambda: (
service.events().get(calendarId=calendar_id, eventId=event_id).execute()
)
)
logger.info("[delete_event] Successfully verified event exists before deletion")
except HttpError as get_error:
@@ -1115,9 +1123,9 @@ async def delete_event(
# Proceed with the deletion
await asyncio.to_thread(
lambda: service.events()
.delete(calendarId=calendar_id, eventId=event_id)
.execute()
lambda: (
service.events().delete(calendarId=calendar_id, eventId=event_id).execute()
)
)
confirmation_message = f"Successfully deleted event (ID: {event_id}) from calendar '{calendar_id}' for {user_google_email}."

View File

@@ -601,7 +601,7 @@ async def _format_sheet_range_impl(
return {
"range_name": range_name,
"spreadsheet_id": spreadsheet_id,
"summary": summary
"summary": summary,
}

2052
uv.lock generated

File diff suppressed because it is too large Load Diff