diff --git a/src/cli/program/message/register.thread.test.ts b/src/cli/program/message/register.thread.test.ts new file mode 100644 index 00000000000..af7e8bd5745 --- /dev/null +++ b/src/cli/program/message/register.thread.test.ts @@ -0,0 +1,14 @@ +import { describe, expect, it } from "vitest"; +import { __test__ } from "./register.thread.js"; + +describe("resolveThreadCreateAction", () => { + it("maps telegram thread create to topic-create", () => { + expect(__test__.resolveThreadCreateAction({ channel: "telegram" })).toBe("topic-create"); + expect(__test__.resolveThreadCreateAction({ channel: " Telegram " })).toBe("topic-create"); + }); + + it("keeps thread-create for non-telegram channels", () => { + expect(__test__.resolveThreadCreateAction({ channel: "discord" })).toBe("thread-create"); + expect(__test__.resolveThreadCreateAction({ channel: undefined })).toBe("thread-create"); + }); +}); diff --git a/src/cli/program/message/register.thread.ts b/src/cli/program/message/register.thread.ts index 7d4365a9915..5f3b5519fe6 100644 --- a/src/cli/program/message/register.thread.ts +++ b/src/cli/program/message/register.thread.ts @@ -1,6 +1,11 @@ import type { Command } from "commander"; import type { MessageCliHelpers } from "./helpers.js"; +function resolveThreadCreateAction(opts: { channel?: unknown }) { + const channel = typeof opts.channel === "string" ? opts.channel.trim().toLowerCase() : ""; + return channel === "telegram" ? "topic-create" : "thread-create"; +} + export function registerMessageThreadCommands(message: Command, helpers: MessageCliHelpers) { const thread = message.command("thread").description("Thread actions"); @@ -17,7 +22,7 @@ export function registerMessageThreadCommands(message: Command, helpers: Message .option("-m, --message ", "Initial thread message text") .option("--auto-archive-min ", "Thread auto-archive minutes") .action(async (opts) => { - await helpers.runMessageAction("thread-create", opts); + await helpers.runMessageAction(resolveThreadCreateAction(opts), opts); }); helpers @@ -53,3 +58,5 @@ export function registerMessageThreadCommands(message: Command, helpers: Message await helpers.runMessageAction("thread-reply", opts); }); } + +export const __test__ = { resolveThreadCreateAction };