Matrix: fix validated review comments

This commit is contained in:
Gustavo Madeira Santana
2026-03-09 08:18:21 -04:00
parent d7402f3815
commit 4ae8558288
7 changed files with 163 additions and 32 deletions

View File

@@ -242,6 +242,28 @@ describe("pairing cli", () => {
});
});
it("uses the approved request accountId for notifications when --account is omitted", async () => {
approveChannelPairingCode.mockResolvedValueOnce({
id: "123",
entry: {
id: "123",
code: "ABCDEFGH",
createdAt: "2026-01-08T00:00:00Z",
lastSeenAt: "2026-01-08T00:00:00Z",
meta: { accountId: "ops" },
},
});
await runPairing(["pairing", "approve", "--channel", "telegram", "--notify", "ABCDEFGH"]);
expect(notifyPairingApproved).toHaveBeenCalledWith({
channelId: "telegram",
id: "123",
cfg: {},
accountId: "ops",
});
});
it("defaults approve to the sole available channel when only code is provided", async () => {
listPairingChannels.mockReturnValueOnce(["slack"]);
mockApprovedPairing();

View File

@@ -166,8 +166,11 @@ export function registerPairingCli(program: Command) {
if (!opts.notify) {
return;
}
await notifyApproved(channel, approved.id, accountId || undefined).catch((err) => {
defaultRuntime.log(theme.warn(`Failed to notify requester: ${String(err)}`));
});
const approvedAccountId = String(approved.entry?.meta?.accountId ?? "").trim();
await notifyApproved(channel, approved.id, accountId || approvedAccountId || undefined).catch(
(err) => {
defaultRuntime.log(theme.warn(`Failed to notify requester: ${String(err)}`));
},
);
});
}