Single isntances and some updates shit.

This commit is contained in:
Burak Kaan Köse
2026-01-06 11:11:37 +01:00
parent d279c0a8dd
commit f8333aab10
18 changed files with 482 additions and 732 deletions
+29 -1
View File
@@ -392,7 +392,10 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
{
var request = _calendarService.Events.List(calendar.RemoteCalendarId);
request.SingleEvents = false;
// Fetch individual event instances (including recurring event occurrences)
// rather than recurring event masters. This ensures we get all occurrences
// as separate events that can be stored and displayed directly.
request.SingleEvents = true;
request.ShowDeleted = true;
if (!string.IsNullOrEmpty(calendar.SynchronizationDeltaToken))
@@ -1975,6 +1978,31 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
return [new HttpRequestBundle<IClientServiceRequest>(updateRequest, request)];
}
public override List<IRequestBundle<IClientServiceRequest>> DeleteCalendarEvent(DeleteCalendarEventRequest request)
{
var calendarItem = request.Item;
// Get the calendar for this event
var calendar = calendarItem.AssignedCalendar;
if (calendar == null)
{
throw new InvalidOperationException("Calendar item must have an assigned calendar");
}
if (string.IsNullOrEmpty(calendarItem.RemoteEventId))
{
throw new InvalidOperationException("Cannot delete event without remote event ID");
}
// Delete the event using Google Calendar API
var deleteRequest = _calendarService.Events.Delete(calendar.RemoteCalendarId, calendarItem.RemoteEventId);
// Send cancellation notifications to attendees
deleteRequest.SendUpdates = Google.Apis.Calendar.v3.EventsResource.DeleteRequest.SendUpdatesEnum.All;
return [new HttpRequestBundle<IClientServiceRequest>(deleteRequest, request)];
}
#endregion
public override async Task KillSynchronizerAsync()
+24 -12
View File
@@ -1811,14 +1811,8 @@ public class OutlookSynchronizer : WinoSynchronizer<RequestInformation, Message,
var messageIteratorAsync = PageIterator<Event, Microsoft.Graph.Me.Calendars.Item.CalendarView.Delta.DeltaGetResponse>.CreatePageIterator(_graphClient, eventsDeltaResponse, (item) =>
{
// Skip occurrence events during initial sync - only sync master recurring events and single instances
// Occurrences are individual instances of recurring events and will be generated from the seriesMaster
if (item.Type == Microsoft.Graph.Models.EventType.Occurrence)
{
_logger.Debug("Skipping occurrence event {EventId} during initial sync", item.Id);
return true; // Skip this occurrence
}
// Include all event types: SingleInstance, SeriesMaster, Occurrence, and Exception
// CalendarView already expands recurring events into individual occurrences
events.Add(item);
return true;
@@ -1835,10 +1829,6 @@ public class OutlookSynchronizer : WinoSynchronizer<RequestInformation, Message,
foreach (var item in events)
{
if (item.Id == "f275fdd0-8622-4e14-8f5d-b73d7f68018f")
{
}
// Declined events are returned as Deleted from the API.
// There is no way to distinguish unfortunately atm.
@@ -2217,6 +2207,28 @@ public class OutlookSynchronizer : WinoSynchronizer<RequestInformation, Message,
return [new HttpRequestBundle<RequestInformation>(updateRequest, request)];
}
public override List<IRequestBundle<RequestInformation>> DeleteCalendarEvent(DeleteCalendarEventRequest request)
{
var calendarItem = request.Item;
// Get the calendar for this event
var calendar = calendarItem.AssignedCalendar;
if (calendar == null)
{
throw new InvalidOperationException("Calendar item must have an assigned calendar");
}
if (string.IsNullOrEmpty(calendarItem.RemoteEventId))
{
throw new InvalidOperationException("Cannot delete event without remote event ID");
}
// Delete the event using Graph API
var deleteRequest = _graphClient.Me.Calendars[calendar.RemoteCalendarId].Events[calendarItem.RemoteEventId].ToDeleteRequestInformation();
return [new HttpRequestBundle<RequestInformation>(deleteRequest, request)];
}
#endregion
public override async Task KillSynchronizerAsync()
+2 -1
View File
@@ -384,7 +384,7 @@ public abstract class WinoSynchronizer<TBaseRequest, TMessageType, TCalendarEven
nativeRequests.AddRange(UpdateCalendarEvent(group.ElementAt(0) as UpdateCalendarEventRequest));
break;
case CalendarSynchronizerOperation.DeleteEvent:
// TODO: Implement DeleteCalendarEvent
nativeRequests.AddRange(DeleteCalendarEvent(group.ElementAt(0) as DeleteCalendarEventRequest));
break;
default:
break;
@@ -511,6 +511,7 @@ public abstract class WinoSynchronizer<TBaseRequest, TMessageType, TCalendarEven
public virtual List<IRequestBundle<TBaseRequest>> CreateCalendarEvent(CreateCalendarEventRequest request) => throw new NotSupportedException(string.Format(Translator.Exception_UnsupportedSynchronizerOperation, this.GetType()));
public virtual List<IRequestBundle<TBaseRequest>> UpdateCalendarEvent(UpdateCalendarEventRequest request) => throw new NotSupportedException(string.Format(Translator.Exception_UnsupportedSynchronizerOperation, this.GetType()));
public virtual List<IRequestBundle<TBaseRequest>> DeleteCalendarEvent(DeleteCalendarEventRequest request) => throw new NotSupportedException(string.Format(Translator.Exception_UnsupportedSynchronizerOperation, this.GetType()));
public virtual List<IRequestBundle<TBaseRequest>> AcceptEvent(AcceptEventRequest request) => throw new NotSupportedException(string.Format(Translator.Exception_UnsupportedSynchronizerOperation, this.GetType()));
public virtual List<IRequestBundle<TBaseRequest>> DeclineEvent(DeclineEventRequest request) => throw new NotSupportedException(string.Format(Translator.Exception_UnsupportedSynchronizerOperation, this.GetType()));
public virtual List<IRequestBundle<TBaseRequest>> OutlookDeclineEvent(OutlookDeclineEventRequest request) => throw new NotSupportedException(string.Format(Translator.Exception_UnsupportedSynchronizerOperation, this.GetType()));