API-Schutz: 100ms Verzögerung bei allen Google API Calls (create, update, delete)
This commit is contained in:
@@ -480,6 +480,7 @@ async def create_google_event(service, calendar_id, data, context=None):
|
|||||||
created = service.events().insert(calendarId=calendar_id, body=event_body).execute()
|
created = service.events().insert(calendarId=calendar_id, body=event_body).execute()
|
||||||
event_id = created['id']
|
event_id = created['id']
|
||||||
log_operation('info', f"Created Google event ID: {event_id}", context=context)
|
log_operation('info', f"Created Google event ID: {event_id}", context=context)
|
||||||
|
await asyncio.sleep(0.1) # Rate limit protection: 100ms delay after each Google API call
|
||||||
return event_id
|
return event_id
|
||||||
except HttpError as e:
|
except HttpError as e:
|
||||||
log_operation('error', f"Google API error creating event: {e}", context=context)
|
log_operation('error', f"Google API error creating event: {e}", context=context)
|
||||||
@@ -513,6 +514,7 @@ async def update_google_event(service, calendar_id, event_id, data, context=None
|
|||||||
try:
|
try:
|
||||||
service.events().update(calendarId=calendar_id, eventId=event_id, body=event_body).execute()
|
service.events().update(calendarId=calendar_id, eventId=event_id, body=event_body).execute()
|
||||||
log_operation('info', f"Updated Google event ID: {event_id}", context=context)
|
log_operation('info', f"Updated Google event ID: {event_id}", context=context)
|
||||||
|
await asyncio.sleep(0.1) # Rate limit protection: 100ms delay after each Google API call
|
||||||
except HttpError as e:
|
except HttpError as e:
|
||||||
log_operation('error', f"Google API error updating event {event_id}: {e}", context=context)
|
log_operation('error', f"Google API error updating event {event_id}: {e}", context=context)
|
||||||
raise
|
raise
|
||||||
@@ -526,6 +528,7 @@ async def delete_google_event(service, calendar_id, event_id, context=None):
|
|||||||
try:
|
try:
|
||||||
service.events().delete(calendarId=calendar_id, eventId=event_id).execute()
|
service.events().delete(calendarId=calendar_id, eventId=event_id).execute()
|
||||||
log_operation('info', f"Deleted Google event ID: {event_id}", context=context)
|
log_operation('info', f"Deleted Google event ID: {event_id}", context=context)
|
||||||
|
await asyncio.sleep(0.1) # Rate limit protection: 100ms delay after each Google API call
|
||||||
except HttpError as e:
|
except HttpError as e:
|
||||||
log_operation('error', f"Google API error deleting event {event_id}: {e}", context=context)
|
log_operation('error', f"Google API error deleting event {event_id}: {e}", context=context)
|
||||||
raise
|
raise
|
||||||
|
|||||||
Reference in New Issue
Block a user