Record sharing 9/14: sync writes mailbox and calendar share rows - #25441
Draft
martmull wants to merge 1 commit into
Draft
Record sharing 9/14: sync writes mailbox and calendar share rows#25441martmull wants to merge 1 commit into
martmull wants to merge 1 commit into
Conversation
Next to every message, thread and calendar event association, the sync writes one FULL row for the channel owner and one EVERYONE READ row, sourced from the channel, so the objects can become PRIVATE later without changing who sees what. A visibility change or an association removal enqueues a rebuild of the channel's rows, a channel deletion removes them, campaign materialization writes them too, and a 2.39 workspace command backfills existing channels.
This was referenced Sep 5, 2026
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.
Eighth PR of the record-sharing stack in merge order (plan number 9), stacked on #25439 (inherited objects). Inert: message, messageThread and calendarEvent stay OPEN until the next PR flips them, so the rows written here are not consulted yet.
What changes
FULLrow for the channel's connected account owner (the workspace member behindconnectedAccount.userWorkspaceId, skipped when that member left) and oneEVERYONEREADrow, bothrowCauseAPPLICATIONwithsourceId= the channel id. A thread or message imported by two mailboxes carries both channels' rows (the unique index keys onsourceId).saveMessagesWithinTransaction, incalendar-save-events.service.ts, and in campaign materialization, which inserts messages and associations directly.RefreshMessageChannelRecordSharesJob/RefreshCalendarChannelRecordSharesJob: one transaction that deletes the channel's rows and rebuilds them from the association table, keyset-paged by 500. An association removal (mailbox cleanup, folder exclusion, blocklist, cancelled or deleted events) enqueues the same rebuild; a channel deletion removes its rows.upgrade:2-39:backfill-channel-record-sharesruns the rebuild for every message and calendar channel of every workspace, skipping workspaces without the recordShare, message or calendarEvent objects, with--dry-run.ConnectedAccountOwnerServiceresolves a connected account's owner to a workspace member (nothing did that in one place before).Ambiguity to decide before PR 10
The plan says "the channel owner for a personal channel, EVERYONE for a share-everything one". Today no channel visibility hides messages from other members at the row level:
METADATAandSUBJECTonly blank fields. To keep today's behaviour, this PR writes theEVERYONEREADrow for every visibility and the owner row on top; the field-level tiers stay in the read hooks. If the intent is thatMETADATAandSUBJECTmailboxes become owner-only once email isPRIVATE, only the visibility rule in the two row builders changes.Things to know
Tests
test/integration/google/messaging/channel-record-shares.integration-spec.ts(6 cases, Google mocks): imported thread and messages carry the owner FULL and EVERYONE READ rows sourced from the channel; a second mailbox importing the same thread adds its own rows; a visibility change rebuilds the rows and removes a stray row; the calendar twin; the backfill dry run writes nothing and two real runs reproduce the live writer's rows exactly. The existing messaging and calendar channel-visibility and channel-deletion-cleanup suites still pass.Stack
Generated by Claude Code