fix(server-runtime): preserve explicit empty route destinations (#1324)
--------- Co-authored-by: Neko <neko@ayaka.moe> Co-authored-by-agent: Sisyphus <clio-agent@sisyphuslabs.ai> Co-authored-by-agent: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -93,6 +93,22 @@ describe('route middleware', () => {
|
||||
expect(collectDestinations(event)).toEqual(['label:env=prod'])
|
||||
})
|
||||
|
||||
it('treats an explicit empty route destination list as the override', () => {
|
||||
const event = createSparkNotifyEvent({
|
||||
data: {
|
||||
id: 'evt-override',
|
||||
eventId: 'spark-override',
|
||||
kind: 'ping',
|
||||
urgency: 'soon',
|
||||
headline: 'hello',
|
||||
destinations: ['module:character'],
|
||||
},
|
||||
route: { destinations: [] },
|
||||
})
|
||||
|
||||
expect(collectDestinations(event)).toEqual([])
|
||||
})
|
||||
|
||||
it('matches destinations by label selector', () => {
|
||||
const peer = createPeer({
|
||||
id: 'peer-2',
|
||||
|
||||
@@ -79,7 +79,7 @@ export function createPolicyMiddleware(policy: RoutingPolicy): RouteMiddleware {
|
||||
}
|
||||
|
||||
export function collectDestinations(event: WebSocketEvent | (Omit<WebSocketEvent, 'metadata'> & Partial<Pick<WebSocketEvent, 'metadata'>>)) {
|
||||
if (event.route?.destinations?.length) {
|
||||
if (event.route?.destinations !== undefined) {
|
||||
return event.route.destinations
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user