carlos / platform Public

console: deleting an account deletes its domain contacts

domain_saved_contacts and domain_contacts rows go in DeleteAccount's own
transaction: personal data nothing reads once the account is gone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev b586e690df299299810d0c741c00bc81259614c7 parent d5fcfa1
2 files changed, +37 −0
  • internal/console/ownership.go +5 −0
  • internal/console/ownership_test.go +32 −0
diff --git a/internal/console/ownership.go b/internal/console/ownership.go
index 3904c25e3..3596277ab 100644
--- a/internal/console/ownership.go
+++ b/internal/console/ownership.go
@@ -842,6 +842,11 @@ func (s *Store) DeleteAccount(accountID int64, now time.Time) error {
`DELETE FROM getting_started_marks WHERE account_id = ?`,
`DELETE FROM memberships WHERE account_id = ?`,
`DELETE FROM invites WHERE account_id = ?`,
+ // Domain contacts are personal data nothing reads once the account
+ // is gone; its registrations (none, checked above) keep their own
+ // registrant copy.
+ `DELETE FROM domain_saved_contacts WHERE account_id = ?`,
+ `DELETE FROM domain_contacts WHERE account_id = ?`,
} {
if _, err := tx.Exec(stmt, accountID); err != nil {
return err
diff --git a/internal/console/ownership_test.go b/internal/console/ownership_test.go
index 1863ef365..d44baa63a 100644
--- a/internal/console/ownership_test.go
+++ b/internal/console/ownership_test.go
@@ -94,3 +94,35 @@ func TestStoreDeleteAccountRechecksObligations(t *testing.T) {
t.Fatalf("obligations = %v %v, want both kept", got, err)
}
}
+
+// Deleting an account removes its domain contacts, saved and legacy, in the
+// same transaction: they are personal data, and nothing reads them once the
+// account is gone. Another account's are kept.
+func TestStoreDeleteAccountRemovesDomainContacts(t *testing.T) {
+ ctx := context.Background()
+ s := openTestStore(t)
+ now := time.Now()
+ id, other := testAccountID(), testAccountID()
+ for i, acct := range []int64{id, other} {
+ if err := s.CreateAccount(acct, "test-del-contacts-"+string(rune('a'+i)), "Testco", "paul@keymail.dev", now); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := s.AddSavedContact(ctx, acct, savedTestContact("jane"), now); err != nil {
+ t.Fatal(err)
+ }
+ if err := s.SetDomainContact(acct, savedTestContact("legacy"), "contact-1"); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := s.DeleteAccount(id, now); err != nil {
+ t.Fatal(err)
+ }
+ for _, table := range []string{"domain_saved_contacts", "domain_contacts"} {
+ if n := countWhere(t, s, table, "account_id = ?", id); n != 0 {
+ t.Errorf("%s: %d row(s) of the deleted account kept", table, n)
+ }
+ if n := countWhere(t, s, table, "account_id = ?", other); n != 1 {
+ t.Errorf("%s: %d row(s) of the other account, want 1", table, n)
+ }
+ }
+}