From 39be854a4a743ea5bd5098eb635aa8dd75876431 Mon Sep 17 00:00:00 2001 From: duffyduck Date: Fri, 3 Apr 2026 18:29:56 +0200 Subject: [PATCH] Propagate contact deletions during sync When a mapped contact is deleted on one side, delete it on the other side too (respecting sync direction setting): - Deleted in Outlook -> delete in Starface (if direction allows) - Deleted in Starface -> delete in Outlook (if direction allows) - Deleted on both sides -> just remove the mapping Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Services/SyncEngine.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) 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; }