fix(scheduling): extend AnonymizeStaleGuestAccounts with additional field scrubbing
AnonymizeStaleGuestAccounts now additionally scrubs profile_pic_url (NULL), referral_code (NULL), notes (NULL), and data_retention_consent (FALSE) for stale guest accounts. Previously only scrubbed name, email, phone, and date_of_birth. Ensures comprehensive PII removal for guests with no active/pending bookings and last booking over 6 months old. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -368,13 +368,17 @@ func CleanupOldReservations(ctx context.Context) error {
|
||||
// Active/pending bookings are excluded so the salon can still contact the guest.
|
||||
func AnonymizeStaleGuestAccounts(ctx context.Context) error {
|
||||
_, err := db.DB.Exec(ctx, `
|
||||
UPDATE users SET
|
||||
n_first_name = 'Guest',
|
||||
n_last_name = 'Anonymized',
|
||||
email = 'anon-' || id || '@anon.invalid',
|
||||
phone = '000000000000',
|
||||
date_of_birth = '1900-01-01',
|
||||
updated_at = NOW()
|
||||
UPDATE users SET
|
||||
n_first_name = 'Guest',
|
||||
n_last_name = 'Anonymized',
|
||||
email = 'anon-' || id || '@anon.invalid',
|
||||
phone = '000000000000',
|
||||
date_of_birth = '1900-01-01',
|
||||
profile_pic_url = NULL,
|
||||
referral_code = NULL,
|
||||
notes = NULL,
|
||||
data_retention_consent = FALSE,
|
||||
updated_at = NOW()
|
||||
WHERE account_role = 'guest'
|
||||
AND id NOT IN (
|
||||
SELECT user_id FROM bookings WHERE status IN ('pending', 'confirmed')
|
||||
|
||||
Reference in New Issue
Block a user