mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-20 06:20:55 +00:00
Plugins: scope SDK imports and harden Matrix routing
This commit is contained in:
@@ -218,6 +218,28 @@ describe("pairing cli", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("forwards --account to approval notifications", async () => {
|
||||
mockApprovedPairing();
|
||||
|
||||
await runPairing([
|
||||
"pairing",
|
||||
"approve",
|
||||
"--channel",
|
||||
"telegram",
|
||||
"--account",
|
||||
"yy",
|
||||
"--notify",
|
||||
"ABCDEFGH",
|
||||
]);
|
||||
|
||||
expect(notifyPairingApproved).toHaveBeenCalledWith({
|
||||
channelId: "telegram",
|
||||
id: "123",
|
||||
cfg: {},
|
||||
accountId: "yy",
|
||||
});
|
||||
});
|
||||
|
||||
it("defaults approve to the sole available channel when only code is provided", async () => {
|
||||
listPairingChannels.mockReturnValueOnce(["slack"]);
|
||||
mockApprovedPairing();
|
||||
|
||||
@@ -44,9 +44,9 @@ function parseChannel(raw: unknown, channels: PairingChannel[]): PairingChannel
|
||||
throw new Error(`Invalid channel: ${value}`);
|
||||
}
|
||||
|
||||
async function notifyApproved(channel: PairingChannel, id: string) {
|
||||
async function notifyApproved(channel: PairingChannel, id: string, accountId?: string) {
|
||||
const cfg = loadConfig();
|
||||
await notifyPairingApproved({ channelId: channel, id, cfg });
|
||||
await notifyPairingApproved({ channelId: channel, id, cfg, accountId });
|
||||
}
|
||||
|
||||
export function registerPairingCli(program: Command) {
|
||||
@@ -166,7 +166,7 @@ export function registerPairingCli(program: Command) {
|
||||
if (!opts.notify) {
|
||||
return;
|
||||
}
|
||||
await notifyApproved(channel, approved.id).catch((err) => {
|
||||
await notifyApproved(channel, approved.id, accountId || undefined).catch((err) => {
|
||||
defaultRuntime.log(theme.warn(`Failed to notify requester: ${String(err)}`));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user