diff --git a/src/cli/pairing-cli.test.ts b/src/cli/pairing-cli.test.ts index 5efb7f729d6..73b81386a0c 100644 --- a/src/cli/pairing-cli.test.ts +++ b/src/cli/pairing-cli.test.ts @@ -94,6 +94,20 @@ describe("pairing cli", () => { expect(listChannelPairingRequests).toHaveBeenCalledWith("telegram"); }); + it("forwards --account for list", async () => { + const { registerPairingCli } = await import("./pairing-cli.js"); + listChannelPairingRequests.mockResolvedValueOnce([]); + + const program = new Command(); + program.name("test"); + registerPairingCli(program); + await program.parseAsync(["pairing", "list", "--channel", "telegram", "--account", "yy"], { + from: "user", + }); + + expect(listChannelPairingRequests).toHaveBeenCalledWith("telegram", process.env, "yy"); + }); + it("normalizes channel aliases", async () => { const { registerPairingCli } = await import("./pairing-cli.js"); listChannelPairingRequests.mockResolvedValueOnce([]); @@ -170,4 +184,33 @@ describe("pairing cli", () => { }); expect(log).toHaveBeenCalledWith(expect.stringContaining("Approved")); }); + + it("forwards --account for approve", async () => { + const { registerPairingCli } = await import("./pairing-cli.js"); + approveChannelPairingCode.mockResolvedValueOnce({ + id: "123", + entry: { + id: "123", + code: "ABCDEFGH", + createdAt: "2026-01-08T00:00:00Z", + lastSeenAt: "2026-01-08T00:00:00Z", + }, + }); + + const program = new Command(); + program.name("test"); + registerPairingCli(program); + await program.parseAsync( + ["pairing", "approve", "--channel", "telegram", "--account", "yy", "ABCDEFGH"], + { + from: "user", + }, + ); + + expect(approveChannelPairingCode).toHaveBeenCalledWith({ + channel: "telegram", + code: "ABCDEFGH", + accountId: "yy", + }); + }); }); diff --git a/src/cli/pairing-cli.ts b/src/cli/pairing-cli.ts index e576d1b5723..f028b08fc33 100644 --- a/src/cli/pairing-cli.ts +++ b/src/cli/pairing-cli.ts @@ -64,6 +64,7 @@ export function registerPairingCli(program: Command) { .command("list") .description("List pending pairing requests") .option("--channel ", `Channel (${channels.join(", ")})`) + .option("--account ", "Account id (for multi-account channels)") .argument("[channel]", `Channel (${channels.join(", ")})`) .option("--json", "Print JSON", false) .action(async (channelArg, opts) => { @@ -74,7 +75,10 @@ export function registerPairingCli(program: Command) { ); } const channel = parseChannel(channelRaw, channels); - const requests = await listChannelPairingRequests(channel); + const accountId = String(opts.account ?? "").trim(); + const requests = accountId + ? await listChannelPairingRequests(channel, process.env, accountId) + : await listChannelPairingRequests(channel); if (opts.json) { defaultRuntime.log(JSON.stringify({ channel, requests }, null, 2)); return; @@ -111,6 +115,7 @@ export function registerPairingCli(program: Command) { .command("approve") .description("Approve a pairing code and allow that sender") .option("--channel ", `Channel (${channels.join(", ")})`) + .option("--account ", "Account id (for multi-account channels)") .argument("", "Pairing code (or channel when using 2 args)") .argument("[code]", "Pairing code (when channel is passed as the 1st arg)") .option("--notify", "Notify the requester on the same channel", false) @@ -128,10 +133,17 @@ export function registerPairingCli(program: Command) { ); } const channel = parseChannel(channelRaw, channels); - const approved = await approveChannelPairingCode({ - channel, - code: String(resolvedCode), - }); + const accountId = String(opts.account ?? "").trim(); + const approved = accountId + ? await approveChannelPairingCode({ + channel, + code: String(resolvedCode), + accountId, + }) + : await approveChannelPairingCode({ + channel, + code: String(resolvedCode), + }); if (!approved) { throw new Error(`No pending pairing request found for code: ${String(resolvedCode)}`); }