From f9f9c38a8be6719704039f94300668d6b12a10a0 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 21 Nov 2021 23:50:35 +0100 Subject: [PATCH] Improved robustness of ICal event parser --- platypush/plugins/calendar/ical/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/platypush/plugins/calendar/ical/__init__.py b/platypush/plugins/calendar/ical/__init__.py index 4f8f02945..c13c0a2d2 100644 --- a/platypush/plugins/calendar/ical/__init__.py +++ b/platypush/plugins/calendar/ical/__init__.py @@ -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