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
: feed.filterMunicipality.id : feed.filterMunicipality.id
filters.push({ municipality: { equals: municipalityId } }) 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 // Defense in depth (C96): an advisor's feed is intersected with the
// municipality the advisor was removed from stops serving it — the creator's // municipality ids the creator currently administers, so a feed (pinned or
// read scope is re-derived on every request (resolveFeedCreatorAccess), never // not) stops serving a municipality the advisor was removed from. The creator's
// trusted from write time. `null` = coordinator/candidate/admin (unrestricted). // read scope is re-derived on every request — never trusted from write time.
if (accessibleMunicipalityIds) { // `null` = coordinator/candidate/admin (unrestricted).
filters.push(advisorMunicipalityScopeWhere('municipality', accessibleMunicipalityIds)) if (accessibleMunicipalityIds) {
}
} else if (accessibleMunicipalityIds) {
filters.push(advisorMunicipalityScopeWhere('municipality', accessibleMunicipalityIds)) filters.push(advisorMunicipalityScopeWhere('municipality', accessibleMunicipalityIds))
} }