fix: make same-chat approvals work across channels
parent
1ca01b738b
commit
574d3c5213
@ -0,0 +1,19 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { hasApprovalTurnSourceRoute } from "./approval-turn-source.js";
|
||||
|
||||
describe("hasApprovalTurnSourceRoute", () => {
|
||||
it("accepts operator UI turn sources", () => {
|
||||
expect(hasApprovalTurnSourceRoute({ turnSourceChannel: "webchat" })).toBe(true);
|
||||
expect(hasApprovalTurnSourceRoute({ turnSourceChannel: "tui" })).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts deliverable chat channels", () => {
|
||||
expect(hasApprovalTurnSourceRoute({ turnSourceChannel: "slack" })).toBe(true);
|
||||
expect(hasApprovalTurnSourceRoute({ turnSourceChannel: "discord" })).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects missing or unknown turn sources", () => {
|
||||
expect(hasApprovalTurnSourceRoute({ turnSourceChannel: undefined })).toBe(false);
|
||||
expect(hasApprovalTurnSourceRoute({ turnSourceChannel: "unknown-channel" })).toBe(false);
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,16 @@
|
||||
import {
|
||||
INTERNAL_MESSAGE_CHANNEL,
|
||||
isDeliverableMessageChannel,
|
||||
normalizeMessageChannel,
|
||||
} from "../utils/message-channel.js";
|
||||
|
||||
export function hasApprovalTurnSourceRoute(params: { turnSourceChannel?: string | null }): boolean {
|
||||
const channel = normalizeMessageChannel(params.turnSourceChannel);
|
||||
if (!channel) {
|
||||
return false;
|
||||
}
|
||||
if (channel === INTERNAL_MESSAGE_CHANNEL || channel === "tui") {
|
||||
return true;
|
||||
}
|
||||
return isDeliverableMessageChannel(channel);
|
||||
}
|
||||
Loading…
Reference in New Issue