Skip to content

Commit

Permalink
Filter out transparent events (Fixes #661) (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn authored Sep 16, 2024
1 parent 41f807e commit 7951d99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions backend/src/appointment/controller/apis/google_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def list_events(self, calendar_id, time_min, time_max, token):
'items/attendees',
'items/start',
'items/end',
'items/transparency',
# Top level stuff
'nextPageToken',
)
Expand Down
9 changes: 6 additions & 3 deletions backend/src/appointment/controller/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,12 @@ def list_events(self, start, end):

events = []
for event in remote_events:
# If the event doesn't have transparency assume its opaque (and thus blocks time) by default.
transparency = event.get('transparency', 'opaque').lower()
status = event.get('status').lower()

# Ignore cancelled events
if status == 'cancelled':
# Ignore cancelled events or non-time blocking events
if status == 'cancelled' or transparency == 'transparent':
continue

# Mark tentative events
Expand Down Expand Up @@ -333,10 +335,11 @@ def list_events(self, start, end):
expand=True,
)
for e in result:
transparency = e.icalendar_component['transp'].lower() if 'transp' in e.icalendar_component else 'opaque'
status = e.icalendar_component['status'].lower() if 'status' in e.icalendar_component else ''

# Ignore cancelled events
if status == 'cancelled':
if status == 'cancelled' or transparency == 'transparent':
continue

# Mark tentative events
Expand Down

0 comments on commit 7951d99

Please sign in to comment.