refactor(C96): flatten advisor scope intersection in buildFeedWhere

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).
This commit is contained in:
Francisco Solla 2026-08-09 01:05:25 -03:00
parent 5b342146d5
commit 313e0ed0c8

View file

@ -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))
}