inovex / CalendarSync

Stateless CLI tool to sync calendars across different calendaring systems.
MIT License
99 stars 13 forks source link

Handle Series #166

Open Trefex opened 2 months ago

Trefex commented 2 months ago

Hi,

I think at the moment series are handled as individual events, whereas they should be handled as series to avoid issues.

Could this be something to add to the roadmap?

Many thanks T

alxndr13 commented 1 month ago

Which issues are you experiencing with series?

Trefex commented 1 month ago

If they are synced as individual events rather than series, you can't update the series in the target calendar in batch mode, eg to set from Busy to Free etc.

alxndr13 commented 1 month ago

ah, that makes sense! Thanks for the headsup!

Trefex commented 1 month ago

I investigated a little bit, and want to share my findings.

For MS 365, there is a field type that can contain singleInstance, occurrence, exception, seriesMaster as possible values. When you target /events you will get a list of only types singleInstance or seriesMaster.

From there, using a startDateTime and endDateTime you can extract all occurrence and exception from a seriesMaster by using the series id and the /events/{event-id}/instances endpoint. Any non-modified instance of a series will be of type occurrence and may not need to be updated, or rather will not be different than the information contained in seriesMaster. Any single instance that has different dates, different body, etc will be of type exception.

From my limited understanding you are not patching events anyway, but just copying all of them.

So the elegant solution would be to handle the types differently, the brute-force approach would be to check for seriesMaster type and then fetch all instances of that series (regardless the type) and just copy all fields to the other entry.

Important to note is that a new field should be tracked / used, which is seriesMasterId which contains the ID of the seriesMaster event.

I am not an expert in Go, and I also do not want to impede on your logic, so do you think this is something you could implement or would you need more information ? @alxndr13

alxndr13 commented 3 weeks ago

@Trefex i will have a look at this when i got the time. Currently i'm kinda busy moving and enjoying the summer :) Will probably tackle this in the winter or so.