fix: finalize rebased device-pair QR changes
This commit is contained in:
parent
caab1fb362
commit
529d4e43ca
@ -7,5 +7,8 @@ export {
|
||||
} from "openclaw/plugin-sdk/device-bootstrap";
|
||||
export { definePluginEntry, type OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry";
|
||||
export { resolveGatewayBindUrl, resolveTailnetHostWithRunner } from "openclaw/plugin-sdk/core";
|
||||
export { resolvePreferredOpenClawTmpDir, runPluginCommandWithTimeout } from "openclaw/plugin-sdk/sandbox";
|
||||
export {
|
||||
resolvePreferredOpenClawTmpDir,
|
||||
runPluginCommandWithTimeout,
|
||||
} from "openclaw/plugin-sdk/sandbox";
|
||||
export { renderQrPngBase64 } from "../whatsapp/src/qr-image.js";
|
||||
|
||||
@ -2,12 +2,12 @@ import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawPluginApi } from "./api.js";
|
||||
import type {
|
||||
OpenClawPluginCommandDefinition,
|
||||
PluginCommandContext,
|
||||
} from "../../src/plugins/types.js";
|
||||
import { createTestPluginApi } from "../../test/helpers/extensions/plugin-api.js";
|
||||
import type { OpenClawPluginApi } from "./api.js";
|
||||
|
||||
const pluginApiMocks = vi.hoisted(() => ({
|
||||
clearDeviceBootstrapTokens: vi.fn(async () => ({ removed: 2 })),
|
||||
@ -20,12 +20,11 @@ const pluginApiMocks = vi.hoisted(() => ({
|
||||
resolvePreferredOpenClawTmpDir: vi.fn(() => path.join(os.tmpdir(), "openclaw-device-pair-tests")),
|
||||
}));
|
||||
|
||||
vi.mock("./api.js", async () => {
|
||||
const actual = await vi.importActual<object>("./api.js");
|
||||
vi.mock("./api.js", () => {
|
||||
return {
|
||||
...actual,
|
||||
approveDevicePairing: vi.fn(),
|
||||
clearDeviceBootstrapTokens: pluginApiMocks.clearDeviceBootstrapTokens,
|
||||
definePluginEntry: vi.fn((entry) => entry),
|
||||
issueDeviceBootstrapToken: pluginApiMocks.issueDeviceBootstrapToken,
|
||||
listDevicePairing: vi.fn(async () => ({ pending: [] })),
|
||||
renderQrPngBase64: pluginApiMocks.renderQrPngBase64,
|
||||
@ -79,6 +78,12 @@ function createCommandContext(params?: Partial<PluginCommandContext>): PluginCom
|
||||
commandBody: "/pair qr",
|
||||
args: "qr",
|
||||
config: {},
|
||||
requestConversationBinding: async () => ({
|
||||
status: "error",
|
||||
message: "unsupported",
|
||||
}),
|
||||
detachConversationBinding: async () => ({ removed: false }),
|
||||
getCurrentConversationBinding: async () => null,
|
||||
...params,
|
||||
};
|
||||
}
|
||||
|
||||
@ -697,8 +697,9 @@ export default definePluginEntry({
|
||||
setupCode = encodeSetupCode(payload);
|
||||
} finally {
|
||||
if (qrFilePath) {
|
||||
await rm(path.dirname(qrFilePath), { recursive: true, force: true }).catch(() => {
|
||||
});
|
||||
await rm(path.dirname(qrFilePath), { recursive: true, force: true }).catch(
|
||||
() => {},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -768,6 +769,7 @@ export default definePluginEntry({
|
||||
)})`,
|
||||
);
|
||||
}
|
||||
}
|
||||
return {
|
||||
text: formatSetupReply(payload, authLabel),
|
||||
};
|
||||
|
||||
@ -263,7 +263,7 @@ async function notifySubscriber(params: {
|
||||
try {
|
||||
await send(params.subscriber.to, params.text, {
|
||||
...(params.subscriber.accountId ? { accountId: params.subscriber.accountId } : {}),
|
||||
...(params.subscriber.messageThreadId != null
|
||||
...(typeof params.subscriber.messageThreadId === "number"
|
||||
? { messageThreadId: params.subscriber.messageThreadId }
|
||||
: {}),
|
||||
});
|
||||
|
||||
@ -322,7 +322,7 @@ function resolveBindingConversationFromCommand(params: {
|
||||
from?: string;
|
||||
to?: string;
|
||||
accountId?: string;
|
||||
messageThreadId?: number;
|
||||
messageThreadId?: string | number;
|
||||
}): {
|
||||
channel: string;
|
||||
accountId: string;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user