Repository navigation
Nightmail customers: every workspace owner on one list in the platform workspace - #991
Merged
Merged
Conversation
…m workspace Everyone who owns a workspace is now a contact of a list named "Nightmail customers" in the platform workspace (NIGHTMAIL_PLATFORM_DOMAIN_WORKSPACE), at the account's verified address, for product news and service status. It is on wherever the platform workspace is configured; nothing is set by hand and nothing is sent. - The list: the first signups.sync run with someone to write makes it and records its ID (nightmail_customers_list, migration 579) in one transaction under an advisory lock, so two runs make one list and a rename changes nothing. Deleted by staff, it stays deleted: nothing more is written and maintenance logs CUSTOMERS_LIST_MISSING hourly; a migration deleting the row makes a new one, written in full. - Who: accounts with a verified address that own a workspace. One source for everyone, sign-ups and accounts let in by an invitation or staff alike, so sign-ups recorded before migration 459 (no address) and the accounts from before sign-ups opened are on it from the start. Teammates who own no workspace are not (one condition, customerAccount); an address that only waited is not. - Each account is written once per list and address (nightmail_customers): signed_up_at is the sign-up's time, else the account's creation, with joined_via sign-up or admitted saying which; email_domain and mailbox as the sign-ups list has them; the sign-up's name, else the account's. - Consent goes through upsertListContact: a contact with no decision is subscribed with the source "Nightmail account" (an account holder, on legitimate interests, not an opt-in); one already subscribed gets the same record (new consentAgain option), so its history says why it is on this list. Consent is one decision per contact in the workspace, so an unsubscribe from any of its mail holds; suppression is never touched; a deleted contact stays deleted. - An account whose address changes moves to the new one; one deleted, owning no workspace or without a verified address comes off within a minute (removeListContact: the membership only). - signups.sync now writes the sign-ups list, then the customers list, each 100 at a time within the run's ten seconds; a missing sign-ups list no longer stops the run, only its own part. An account whose sign-up is still due for the sign-ups list waits for it, so that list's consent comes first. Migration 579 creates two tables and locks or rewrites nothing that exists. 578 is taken by an open pull request. Verified (Mac Studio lab): the new acceptance test (backfill, a new sign-up joining, a teammate, an unverified address and a waiting address staying off, opt-out, suppression and deleted contact untouched, two runs at once making one list, a rename, a deleted account, a changed address, a deleted list not made again, and remaking it) and the sign-up limit test pass. A backfill of 5,000 owners and 2,000 waiting addresses, with sign-ins every 100 ms, wrote every owner in 7 runs (51 s), at 14 queries an account; type-check and check-premerge pass.
The "Nightmail account" consent record now carries a policy version,
CUSTOMERS_NOTICE ("Privacy Policy and Terms of 26 November 2026": the
policy and terms that say customers get product news and service status
emails, published with the line under every sign-in button), in the
field the consent route and imports already fill. The record stays dated
when the account signed up or was made, so one dated before the notice
belongs to someone who signed up before it existed; the evidence now says
so, and signed_up_at stays what a send filters on. upsertListContact
passes a consent's policy version through to recordConsent.
api/README.md now says that bringing a deleted list back takes a
one-line migration, and that remaking it also takes everyone off the old
list if that list still exists; and that properties and name are the
contact's, shared with the sign-ups list (its contacts gain joined_via,
and an account let in that it holds from the waitlist gains
signed_up_at and the account's name).
Both are a reviewer's suggestions. Verified in the lab: the customers
test (now also asserting the policy version) and the sign-up limit test
pass; bun run check passes.
…ery record The "Nightmail account" record is dated with the sign-up's time, or the account's creation for an account let in. The sign-up row is written in the transaction that creates the account and both default to now(), so the two are the same instant: "Dated when the account was created" is true for every record, where "signed up" was not for the 8 let-in accounts. Only that phrase changes. Verified in the lab: bun run check, check-premerge (base 855d159) and the customers and sign-up limit acceptance tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every account that owns a workspace becomes a contact of one list, Nightmail customers, in the platform workspace (
NIGHTMAIL_PLATFORM_DOMAIN_WORKSPACE), at the account's verified address. The list is for product news and service status. This sends nothing.Do not merge until #990 (the policy and the line under the sign-in button) is live in production. Auto-merge is off.
What it does
signups.syncrun that has someone to write makes the list and records its ID innightmail_customers_list(migration 579). This happens in one transaction under an advisory lock, so two runs at once make one list. The list is found by ID, so renaming it in the dashboard changes nothing. No new setting, secret or ID is needed in production: it is on wherever the platform workspace is configured.CUSTOMERS_LIST_MISSINGhourly. Bringing it back takes a one-line migration that deletes the row; the next run makes a new list and writes every account to it. Remaking it also takes everyone off the old list if that list still exists (renamed rather than deleted).joined_via. The 8 accounts let in gainsigned_up_at(their account's creation) and, where the sign-ups list holds them from the waitlist, take their account's name in place of their waitlist name.role='owner'condition incustomerAccount; dropping it adds them).signed_up_at(ISO 8601, UTC): the sign-up's time, or the account's creation for an account let in.joined_via:sign-uporadmitted, saying which of the twosigned_up_atis.email_domainandmailbox, as the sign-ups list has them.upsertListContact. Each record's policy version names the notice it rests on,CUSTOMERS_NOTICE("Privacy Policy and Terms of 26 November 2026", from Legal: product news and service status emails, under the sign-in button and in the policies #990). If Legal: product news and service status emails, under the sign-in button and in the policies #990 merges on a later day and itsupdateddate changes, this constant changes with it. A record is dated when the account signed up or was made, so one dated before the notice belongs to someone who signed up before it existed; it doesn't claim they saw it.signed_up_atis what a send filters on.signups.syncnow writes the sign-ups list, then this list, 100 at a time within its ten-second run, and defers while more is due. A missing sign-ups list now stops only its own part. An account whose sign-up is still due for the sign-ups list waits for it, so that list's consent record comes first.The first production run: what right looks like
Counts from the production replica before deploy (counts only):
Check within two minutes of the deploy
CUSTOMERS_LIST_CREATEDlogCUSTOMERS_LIST_SYNCEDlogs, summedadded7,updated366; noskipped,deletedorinvalidnightmail_customersrows (accounts written)audience_consent_auditrows with sourceNightmail accountin the platform workspaceoperation.publishjobs (contact.subscription_changed)addedis above 7: some owners' verified address differs from the address their sign-ups contact was made with, an address changed since sign-up. That is expected, not a fault.On the replica (counts only):
Migration 579
It creates two tables (
nightmail_customers_list,nightmail_customers) and takes no lock on any existing table. 578 is used by an open pull request.nightmail_customershas no foreign key to accounts on purpose: a deleted account's row stays until its membership has been removed, which takes about a minute.Verified
pg_stat_activityevery 50 ms).integration-restacceptance shard (lab): 307 pass, 0 fail, no deadlocks.bun run checkandcheck-premergepass.