improve timezone discovery
This commit is contained in:
@@ -15,6 +15,7 @@ from app.schemas import (
|
||||
AvailabilityRequest,
|
||||
AvailabilityResponse,
|
||||
ParticipantCreate,
|
||||
ParticipantUpdate,
|
||||
ParticipantResponse,
|
||||
SyncResponse,
|
||||
ScheduleRequest,
|
||||
@@ -63,6 +64,7 @@ async def create_participant(
|
||||
participant = Participant(
|
||||
name=data.name,
|
||||
email=data.email,
|
||||
timezone=data.timezone,
|
||||
ics_url=data.ics_url,
|
||||
)
|
||||
db.add(participant)
|
||||
@@ -95,6 +97,35 @@ async def get_participant(participant_id: UUID, db: AsyncSession = Depends(get_d
|
||||
return participant
|
||||
|
||||
|
||||
@app.patch("/api/participants/{participant_id}", response_model=ParticipantResponse)
|
||||
async def update_participant(
|
||||
participant_id: UUID, data: ParticipantUpdate, db: AsyncSession = Depends(get_db)
|
||||
):
|
||||
result = await db.execute(
|
||||
select(Participant).where(Participant.id == participant_id)
|
||||
)
|
||||
participant = result.scalar_one_or_none()
|
||||
if not participant:
|
||||
raise HTTPException(status_code=404, detail="Participant not found")
|
||||
|
||||
if data.timezone is not None:
|
||||
participant.timezone = data.timezone
|
||||
if data.ics_url is not None:
|
||||
participant.ics_url = data.ics_url if data.ics_url else None
|
||||
|
||||
await db.commit()
|
||||
await db.refresh(participant)
|
||||
|
||||
# Re-sync calendar if ICS URL was updated
|
||||
if data.ics_url is not None and participant.ics_url:
|
||||
try:
|
||||
await sync_participant_calendar(db, participant)
|
||||
except Exception as e:
|
||||
logger.warning(f"Calendar sync failed for {participant.email}: {e}")
|
||||
|
||||
return participant
|
||||
|
||||
|
||||
@app.delete("/api/participants/{participant_id}")
|
||||
async def delete_participant(participant_id: UUID, db: AsyncSession = Depends(get_db)):
|
||||
result = await db.execute(
|
||||
|
||||
Reference in New Issue
Block a user