From 61f47ef0f94d7a516e64e3ba8f28b9d1f74bed31 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Mon, 28 Jul 2025 01:19:05 -0600 Subject: [PATCH] - Do not send notifications if end time is more than 1 minute in the past (buffer) --- radicale/hook/email/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/radicale/hook/email/__init__.py b/radicale/hook/email/__init__.py index 2a47d71a..5da4ad04 100644 --- a/radicale/hook/email/__init__.py +++ b/radicale/hook/email/__init__.py @@ -199,6 +199,7 @@ def event_details_other_than_attendees_changed(original_event: 'Event', """ Check if any details other than attendees and IDs have changed between two events. """ + def hash_dict(d: Dict[str, Any]) -> str: """ Create a hash of the dictionary to compare contents. @@ -948,6 +949,20 @@ class Hook(BaseHook): return email_event: EmailEvent = _read_event(vobject_data=new_item_str) # type: ignore + if not email_event: + logger.error("Failed to read event from new content: %s", new_item_str) + return + email_event_event = email_event.event # type: ignore + if not email_event_event: + logger.error("Event could not be parsed from the new content: %s", new_item_str) + return + email_event_end_time = email_event_event.datetime_end # type: ignore + # Skip notification if the event end time is more than 1 minute in the past. + if email_event_end_time and email_event_end_time.time and email_event_end_time.time < ( + datetime.now() - timedelta(minutes=1)): + logger.warning("Event end time is in the past, skipping notification for event: %s", + email_event_event.uid) + return if not previous_item_str: # Dealing with a completely new event, no previous content to compare against.