@bobfrankston/rmfmail 1.0.505 → 1.0.510

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -588,6 +588,28 @@ export class WebMailxDB {
588
588
 
589
589
  // ── Contacts ──
590
590
 
591
+ /** Delete every contact row tied to a single Google contact identity
592
+ * (resourceName like "people/c12345"). Used by the People-API
593
+ * incremental sync when Google flags a contact as deleted. A single
594
+ * Google contact can have multiple email-rows; remove them all. */
595
+ deleteContactByGoogleId(googleId: string): number {
596
+ if (!googleId) return 0;
597
+ const before = (this.get("SELECT COUNT(*) as c FROM contacts WHERE google_id = ?", [googleId]) as any)?.c || 0;
598
+ this.run("DELETE FROM contacts WHERE google_id = ?", [googleId]);
599
+ return before;
600
+ }
601
+
602
+ /** Stamp the google_id + organization on an already-recorded contact row.
603
+ * Web side mirrors mailx-store/db.ts — the Google sync calls
604
+ * `recordSentAddress` first to upsert, then this to attach the
605
+ * Google identity for incremental delete tracking. */
606
+ setContactGoogleId(email: string, googleId: string, organization: string): void {
607
+ if (!email) return;
608
+ this.run(
609
+ "UPDATE contacts SET source = 'google', google_id = ?, organization = ?, updated_at = ? WHERE email = ?",
610
+ [googleId, organization || "", Date.now(), email]);
611
+ }
612
+
591
613
  recordSentAddress(name: string, email: string): void {
592
614
  if (isJunkContact(email, name)) return;
593
615
  const now = Date.now();