From 313e0ed0c8d8c8920070eeceec3715909967bda4 Mon Sep 17 00:00:00 2001 From: Francisco Solla Date: Sun, 9 Aug 2026 01:05:25 -0300 Subject: [PATCH] refactor(C96): flatten advisor scope intersection in buildFeedWhere MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplify reviewer: the duplicated scope fragment push after the filter branch is flattened into a single standalone guard, preserving exact semantics across all four corners (filter set/unset × scope null/non-null). --- src/utilities/calendarFeed.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/utilities/calendarFeed.ts b/src/utilities/calendarFeed.ts index 343b2647..eda6f06c 100644 --- a/src/utilities/calendarFeed.ts +++ b/src/utilities/calendarFeed.ts @@ -107,15 +107,13 @@ const buildFeedWhere = ( ? feed.filterMunicipality : feed.filterMunicipality.id filters.push({ municipality: { equals: municipalityId } }) - // Defense in depth (C96): an advisor's feed is intersected with the - // municipality ids the creator currently administers, so a feed pinned to a - // municipality the advisor was removed from stops serving it — the creator's - // read scope is re-derived on every request (resolveFeedCreatorAccess), never - // trusted from write time. `null` = coordinator/candidate/admin (unrestricted). - if (accessibleMunicipalityIds) { - filters.push(advisorMunicipalityScopeWhere('municipality', accessibleMunicipalityIds)) - } - } else if (accessibleMunicipalityIds) { + } + // Defense in depth (C96): an advisor's feed is intersected with the + // municipality ids the creator currently administers, so a feed (pinned or + // not) stops serving a municipality the advisor was removed from. The creator's + // read scope is re-derived on every request — never trusted from write time. + // `null` = coordinator/candidate/admin (unrestricted). + if (accessibleMunicipalityIds) { filters.push(advisorMunicipalityScopeWhere('municipality', accessibleMunicipalityIds)) }