Skip to content

Commit

Permalink
Adjust how caldav connections are tested, and only pull in supported …
Browse files Browse the repository at this point in the history
…calendars
  • Loading branch information
MelissaAutumn committed Oct 10, 2024
1 parent 9f739e5 commit d941d80
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions backend/src/appointment/controller/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,18 +307,18 @@ def test_connection(self) -> bool:
for cal in cals.calendars():
supported_comps = cal.get_supported_components()
supports_vevent = 'VEVENT' in supported_comps
if not supports_vevent:
# If one supports it, then that's good enough!
if supports_vevent:
break
except IndexError as ex: # Library has an issue with top level urls, probably due to caldav spec?
logging.error(f'IE: Error testing connection {ex}')
return False
except KeyError as ex:
print(ex)
logging.error(f'KE: Error testing connection {ex}')
return False
except requests.exceptions.RequestException: # Max retries exceeded, bad connection, missing schema, etc...
except requests.exceptions.RequestException as ex: # Max retries exceeded, bad connection, missing schema, etc...
return False
except caldav.lib.error.NotFoundError: # Good server, bad url.
except caldav.lib.error.NotFoundError as ex: # Good server, bad url.
return False

# They need at least VEVENT support for appointment to work.
Expand All @@ -329,6 +329,12 @@ def sync_calendars(self):

principal = self.client.principal()
for cal in principal.calendars():
# Does this calendar support vevents?
supported_comps = cal.get_supported_components()

if 'VEVENT' not in supported_comps:
continue

calendar = schemas.CalendarConnection(
title=cal.name,
url=str(cal.url),
Expand Down

0 comments on commit d941d80

Please sign in to comment.