fix: decouple approval availability from native delivery enablement (#59620)

getActionAvailabilityState in createApproverRestrictedNativeApprovalAdapter
was gating on both hasApprovers AND isNativeDeliveryEnabled, causing
Telegram exec approvals to report "not allowed" when
channels.telegram.execApprovals.target was configured but
execApprovals.enabled was not explicitly true. The availability check
should only depend on whether approvers exist; native delivery mode is
a routing concern handled downstream.
This commit is contained in:
joelnishanth
2026-04-02 10:58:35 -05:00
committed by Peter Steinberger
parent 9b48a4d90a
commit d5865bbcc2
2 changed files with 26 additions and 2 deletions

View File

@@ -106,7 +106,7 @@ describe("createApproverRestrictedNativeApprovalAdapter", () => {
accountId: "disabled",
action: "approve",
}),
).toEqual({ kind: "disabled" });
).toEqual({ kind: "enabled" });
expect(hasConfiguredDmRoute.hasConfiguredDmRoute({ cfg: {} as never })).toBe(true);
expect(nativeCapabilities).toEqual({
enabled: true,
@@ -117,6 +117,30 @@ describe("createApproverRestrictedNativeApprovalAdapter", () => {
});
});
it("reports enabled when approvers exist even if native delivery is off (#59620)", () => {
const adapter = createApproverRestrictedNativeApprovalAdapter({
channel: "telegram",
channelLabel: "Telegram",
listAccountIds: () => ["default"],
hasApprovers: () => true,
isExecAuthorizedSender: () => true,
isNativeDeliveryEnabled: () => false,
resolveNativeDeliveryMode: () => "both",
});
const getActionAvailabilityState = adapter.auth.getActionAvailabilityState;
if (!getActionAvailabilityState) {
throw new Error("approval availability helper unavailable");
}
expect(
getActionAvailabilityState({
cfg: {} as never,
accountId: "default",
action: "approve",
}),
).toEqual({ kind: "enabled" });
});
it("suppresses forwarding fallback only for matching native-delivery surfaces", () => {
const isNativeDeliveryEnabled = vi.fn(
({ accountId }: { accountId?: string | null }) => accountId === "topic-1",

View File

@@ -92,7 +92,7 @@ function buildApproverRestrictedNativeApprovalCapability(
accountId?: string | null;
action: "approve";
}) =>
params.hasApprovers({ cfg, accountId }) && params.isNativeDeliveryEnabled({ cfg, accountId })
params.hasApprovers({ cfg, accountId })
? ({ kind: "enabled" } as const)
: ({ kind: "disabled" } as const),
approvals: {