diff --git a/src/StarfaceOutlookSync/Services/SyncEngine.cs b/src/StarfaceOutlookSync/Services/SyncEngine.cs index 3b4057f5..cb96917c 100644 --- a/src/StarfaceOutlookSync/Services/SyncEngine.cs +++ b/src/StarfaceOutlookSync/Services/SyncEngine.cs @@ -144,6 +144,45 @@ namespace StarfaceOutlookSync.Services if (oc == null && sc == null) { // Beide Seiten geloescht -> Mapping entfernen + Log($" Mapping verwaist (beide geloescht), entferne"); + continue; + } + + if (oc == null && sc != null) + { + // In Outlook geloescht -> in Starface auch loeschen + if (profile.SyncDirection == SyncDirection.Both || profile.SyncDirection == SyncDirection.OutlookToStarface) + { + if (await starface.DeleteContactAsync(mapping.StarfaceId)) + { + result.Updated++; + Log($" Geloescht (OL->SF): {sc.DisplayName}"); + } + } + else + { + // Richtung erlaubt kein Loeschen -> Mapping behalten + newMappings.Add(mapping); + } + continue; + } + + if (oc != null && sc == null) + { + // In Starface geloescht -> in Outlook auch loeschen + if (profile.SyncDirection == SyncDirection.Both || profile.SyncDirection == SyncDirection.StarfaceToOutlook) + { + if (_outlookService.DeleteContact(mapping.OutlookEntryId)) + { + result.Updated++; + Log($" Geloescht (SF->OL): {oc.DisplayName}"); + } + } + else + { + // Richtung erlaubt kein Loeschen -> Mapping behalten + newMappings.Add(mapping); + } continue; }