fix(cli): route telegram thread create to topic-create

This commit is contained in:
Andy
2026-03-25 15:36:35 +08:00
committed by Ayaan Zaidi
parent 4140100807
commit e1cd90db6e
2 changed files with 22 additions and 1 deletions

View File

@@ -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");
});
});

View File

@@ -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 <text>", "Initial thread message text")
.option("--auto-archive-min <n>", "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 };