Fix: recreate genuinely-deleted Starface contacts instead of keeping dead mapping
Der vorherige Fix war zu konservativ: bei einem in der geladenen Liste fehlenden Starface-Kontakt wurde das Mapping immer behalten und nichts neu angelegt - auch wenn der Kontakt in Starface wirklich geloescht war. In Richtung Outlook->Starface wurden geloeschte Kontakte dadurch nie wieder angelegt. Jetzt wird der Kontakt per ID abgefragt: - existiert noch (anderes Adressbuch) -> Mapping behalten, nichts anlegen - 404 (wirklich geloescht) -> in Both/OutlookToStarface neu anlegen (Phase 2), in StarfaceToOutlook Loeschung nach Outlook spiegeln Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -181,15 +181,44 @@ namespace StarfaceOutlookSync.Services
|
||||
|
||||
if (oc != null && sc == null)
|
||||
{
|
||||
// Starface-Kontakt nicht in der geladenen Liste.
|
||||
// Da unvollstaendige Ladevorgaenge inzwischen abgebrochen
|
||||
// werden (siehe StarfaceApiClient), liegt das hoechstens an
|
||||
// einem anderen Adressbuch. NICHT loeschen und NICHT neu
|
||||
// anlegen - sonst entstehen Dubletten. Mapping behalten,
|
||||
// beim naechsten Sync wird es erneut abgeglichen.
|
||||
Log($" Starface-Kontakt nicht in Liste (anderes Adressbuch?), behalte Mapping: {oc.DisplayName}");
|
||||
newMappings.Add(mapping);
|
||||
continue;
|
||||
// Starface-Kontakt nicht in der geladenen Liste. Zwei Faelle
|
||||
// unterscheiden, indem wir ihn per ID direkt abfragen:
|
||||
// (a) per ID noch vorhanden -> liegt in einem ANDEREN
|
||||
// Adressbuch -> Mapping behalten, NICHT neu anlegen
|
||||
// (sonst Dublette).
|
||||
// (b) per ID 404 -> in Starface WIRKLICH geloescht.
|
||||
bool stillExists = !string.IsNullOrEmpty(mapping.StarfaceId)
|
||||
&& await starface.GetContactAsync(mapping.StarfaceId) != null;
|
||||
|
||||
if (stillExists)
|
||||
{
|
||||
Log($" Starface-Kontakt in anderem Adressbuch, behalte Mapping: {oc.DisplayName}");
|
||||
newMappings.Add(mapping);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Wirklich geloescht.
|
||||
if (profile.SyncDirection == SyncDirection.Both
|
||||
|| profile.SyncDirection == SyncDirection.OutlookToStarface)
|
||||
{
|
||||
// Outlook ist (mit-)fuehrend -> Kontakt in Starface neu
|
||||
// anlegen. Mapping verwerfen und oc wieder freigeben,
|
||||
// damit Phase 2 ihn anlegt (inkl. Duplikat-Pruefung).
|
||||
Log($" Starface-Kontakt geloescht, wird neu angelegt: {oc.DisplayName}");
|
||||
processedOutlookIds.Remove(oc.OutlookEntryId);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// StarfaceToOutlook: Starface ist fuehrend, Loeschung
|
||||
// nach Outlook spiegeln.
|
||||
if (_outlookService.DeleteContact(oc.OutlookEntryId))
|
||||
{
|
||||
result.Updated++;
|
||||
Log($" Geloescht (SF->OL): {oc.DisplayName}");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (oc != null && sc != null)
|
||||
|
||||
Reference in New Issue
Block a user