Remove the IS_CHANNEL_VISIBILITY_RLS_ENABLED feature flag

Merged
CH
10d ago
+1080-670

Why

Channel visibility through individual roles is the way message and calendar content is protected from now on. This removes IS_CHANNEL_VISIBILITY_RLS_ENABLED and keeps the flag-on behaviour everywhere. Next in the series removing the permission flags (after #31486 and #31499).

Prerequisite and what this turns on

Do not merge before channel-visibility:revoke-role-wide-access has run on every existing workspace.

With the flag on, the message, calendar event and attachment query hooks no longer mask content for workspace members: they rely on each member's individual role, which only restricts anything once role wide read on the channel objects is revoked.

  • New workspaces, created or seeded, now revoke it themselves: workspace creation and the dev seed run the same revoke as the command once their default roles exist. The command's logic moves to ChannelVisibilityRoleWideAccessRevokeService and the command delegates to it.
  • A workspace where the command has not run still lets members read the subject, text and attachments of every message, and the title and description of every calendar event.
  • A user role created later keeps role wide read on the channel objects unless it is set otherwise: granting a role access to every message stays possible on purpose.
  • Individual roles are always synced, for every member and for API keys, whenever a member or a channel changes.

IS_CHANNEL_VISIBILITY_ENFORCED_ON_API_KEYS stays: with this PR it alone decides whether API keys on a role assignable to users read through the API keys individual role.

What changes

  • isChannelVisibilityRlsEnabled is deleted. isChannelVisibilityEnforcedByIndividualRole only checks that the caller is a user, and isApiKeyExemptFromChannelVisibility only reads the API key flag.
  • ChannelVisibilityRuleSyncSchedulerService.scheduleSyncIfEnabled is removed; its 14 callers call scheduleSync.
  • The sync listener no longer listens to feature flag changes, the sync service always writes the individual role rules, and the revoke command no longer skips workspaces without the flag.
  • The three query hooks no longer read the feature flags; the calendar event and message hooks drop their WorkspaceCacheService dependency.
  • The key is removed from FeatureFlagKey, the dev seeder, the admin panel list and the generated schemas (front and client SDK). Leftover featureFlag rows are ignored, same as previous flag removals. No upgrade command is touched.

Tests

The seeded workspace now starts without role wide access to the channel objects, like a new workspace.

  • Specs that are not about channel visibility but write or read messages, threads, participants, calendar events, message attachments or call recordings as the seeded admin, or that assert the exact permissions of seeded roles, give the seeded user roles their role wide access back in beforeAll and revoke it again in afterAll (grantRoleWideAccessToChannelObjects / revokeRoleWideAccessToChannelObjects). A workspace can choose to set its roles that way, so these specs keep testing their own behaviour. The grant only removes the rows and rules the revoke wrote.
  • channel-visibility-rules grants while it creates its records, then revokes and syncs before asserting.
  • message-visibility and calendar-event-visibility query as an API key, with role wide access granted: the hooks still mask for callers other than workspace members.
  • The Google messaging and calendar visibility specs sync the rules first and after each visibility change, and look records up by id, since an unreadable subject or title cannot be filtered on.
  • The new workspace grant spec now expects twenty-standard's grant to equal Admin before its channel objects were revoked: application roles keep full access.
  • timeline-thread-channel-filter and app-message-channels expect a member whose role cannot read message threads to reach the channel through their individual role.
  • Specs reading a member's role targets skip the individual role (findUserWorkspaceRoleTargets), which also fixes the member role restore in arrangeMemberWithPermissionFlags.

Screenshots

No UI change.

Validation

Server typecheck, lint:diff-with-main on server and front, and 174 unit suites (1,530 tests) across permissions, messaging, calendar and the channel metadata modules.