From 15786173136a56c5daa5b42aa69936f688b47675 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 1 May 2024 11:49:53 +0100 Subject: [PATCH] Ensure calendars see separate events Not having a unique UID causes issues in some calendar applications. Similarly, there seemed to be odd mutation issues when doing a shallow clone. We also only loop through the `VEVENT` objects, as these are the only ones we care about right now. --- calmerge/calendars.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/calmerge/calendars.py b/calmerge/calendars.py index 823489e..cb0bba9 100644 --- a/calmerge/calendars.py +++ b/calmerge/calendars.py @@ -1,5 +1,7 @@ import asyncio +from copy import deepcopy from datetime import timedelta +from uuid import uuid4 import icalendar from aiocache import Cache @@ -53,10 +55,12 @@ def create_offset_calendar_events( Mutate a calendar and add additional events at given offsets """ new_components = [] - - for component in calendar.walk(): + for component in calendar.walk("VEVENT"): for days in duplicate_days: - day_component = component.copy() + day_component = deepcopy(component) + + # Create a new ID so calendar software shows it as a different event + day_component["UID"] = str(uuid4()) shift_event_by_offset(day_component, timedelta(days=days))