Improved robustness of ICal event parser

This commit is contained in:
Fabio Manganiello 2021-11-21 23:50:35 +01:00
parent 518d9f20c6
commit f9f9c38a8b
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -79,14 +79,16 @@ class CalendarIcalPlugin(Plugin, CalendarInterface):
event = self._translate_event(event)
if event['status'] and event['responseStatus'] \
and dateutil.parser.parse(event['end']['dateTime']) >= \
datetime.datetime.now(pytz.timezone('UTC')) \
if (
event['status'] != 'cancelled'
and event['end']['dateTime']
and dateutil.parser.parse(event['end']['dateTime']).replace(tzinfo=pytz.timezone('UTC')) >=
datetime.datetime.now(pytz.timezone('UTC'))
and (
(only_participating
and event['status'] == 'confirmed'
and event['responseStatus'] in ['accepted', 'tentative'])
or not only_participating):
and event.get('responseStatus') in [None, 'accepted', 'tentative'])
or not only_participating)
):
events.append(event)
return events