mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-21 01:23:40 +00:00
fix(dispatch): honor stop on a matching fallback route
Once a fallback matches with stop enabled, skip later routes of the same group without affecting other groups. Cover multiple fallback routes in the group-isolation regression test.
This commit is contained in:
1 parent
a2ad4f699e
commit
3e44c0b659
2 files changed
+5
-3
No files matched your search
@@ -98,6 +98,7 @@ export async function dispatchEvent(
|
|||||||
if (route.fallback) {
|
if (route.fallback) {
|
||||||
if (!regularMatched.has(scope) && matchRoute(route, event)) {
|
if (!regularMatched.has(scope) && matchRoute(route, event)) {
|
||||||
tasks.push(processRoute(route));
|
tasks.push(processRoute(route));
|
||||||
|
if (route.stop) stopped.add(scope);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ describe("dispatchEvent fallback routing", () => {
|
|||||||
route("alpha-later", "alpha", {}, "302"),
|
route("alpha-later", "alpha", {}, "302"),
|
||||||
route("zeta-push", "zeta", {}, "303"),
|
route("zeta-push", "zeta", {}, "303"),
|
||||||
route("zeta-catch-all", "zeta", { fallback: true, filters: [] }, "304"),
|
route("zeta-catch-all", "zeta", { fallback: true, filters: [] }, "304"),
|
||||||
route("omega-catch-all", "omega", { fallback: true, filters: [] }, "305"),
|
route("omega-catch-all", "omega", { fallback: true, stop: true, filters: [] }, "305"),
|
||||||
route("omega-catch-all-2", "omega", { fallback: true, filters: [] }, "306"),
|
route("omega-catch-all-2", "omega", { fallback: true, filters: [] }, "306"),
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -251,10 +251,11 @@ describe("dispatchEvent fallback routing", () => {
|
|||||||
expect(hits("301")).toBe(1);
|
expect(hits("301")).toBe(1);
|
||||||
expect(hits("302")).toBe(0);
|
expect(hits("302")).toBe(0);
|
||||||
expect(hits("303")).toBe(1);
|
expect(hits("303")).toBe(1);
|
||||||
// zeta matched a regular route, omega did not: only omega's fallbacks fire.
|
// zeta matched a regular route, omega did not: only omega's fallback fires,
|
||||||
|
// and its `stop` keeps omega's later fallback silent.
|
||||||
expect(hits("304")).toBe(0);
|
expect(hits("304")).toBe(0);
|
||||||
expect(hits("305")).toBe(1);
|
expect(hits("305")).toBe(1);
|
||||||
expect(hits("306")).toBe(1);
|
expect(hits("306")).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("prepends role mentions to the Discord message content", async () => {
|
it("prepends role mentions to the Discord message content", async () => {
|
||||||
|
|||||||
Reference in new issue
Block a user