mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-20 13:13:06 +00:00
fix: honor imessage probe account config
This commit is contained in:
@@ -41,8 +41,15 @@ export async function notifyIMessageApproval(id: string): Promise<void> {
|
||||
await sendMessageIMessage(id, PAIRING_APPROVED_MESSAGE);
|
||||
}
|
||||
|
||||
export async function probeIMessageAccount(timeoutMs?: number) {
|
||||
return await probeIMessage(timeoutMs);
|
||||
export async function probeIMessageAccount(params?: {
|
||||
timeoutMs?: number;
|
||||
cliPath?: string;
|
||||
dbPath?: string;
|
||||
}) {
|
||||
return await probeIMessage(params?.timeoutMs, {
|
||||
cliPath: params?.cliPath,
|
||||
dbPath: params?.dbPath,
|
||||
});
|
||||
}
|
||||
|
||||
export async function startIMessageGatewayAccount(
|
||||
|
||||
@@ -193,8 +193,12 @@ export const imessagePlugin: ChannelPlugin<ResolvedIMessageAccount, IMessageProb
|
||||
cliPath: snapshot.cliPath ?? null,
|
||||
dbPath: snapshot.dbPath ?? null,
|
||||
}),
|
||||
probeAccount: async ({ timeoutMs }) =>
|
||||
await (await loadIMessageChannelRuntime()).probeIMessageAccount(timeoutMs),
|
||||
probeAccount: async ({ account, timeoutMs }) =>
|
||||
await (await loadIMessageChannelRuntime()).probeIMessageAccount({
|
||||
timeoutMs,
|
||||
cliPath: account.config.cliPath,
|
||||
dbPath: account.config.dbPath,
|
||||
}),
|
||||
resolveAccountSnapshot: ({ account, runtime }) => ({
|
||||
accountId: account.accountId,
|
||||
name: account.name,
|
||||
|
||||
@@ -2,6 +2,8 @@ import * as processRuntime from "openclaw/plugin-sdk/process-runtime";
|
||||
import * as setupRuntime from "openclaw/plugin-sdk/setup";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import * as clientModule from "./client.js";
|
||||
import { imessagePlugin } from "./channel.js";
|
||||
import * as channelRuntimeModule from "./channel.runtime.js";
|
||||
import {
|
||||
resolveIMessageGroupRequireMention,
|
||||
resolveIMessageGroupToolPolicy,
|
||||
@@ -260,4 +262,41 @@ describe("probeIMessage", () => {
|
||||
expect(result.error).toMatch(/rpc/i);
|
||||
expect(createIMessageRpcClientMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("status probe uses account-scoped cliPath and dbPath", async () => {
|
||||
const probeAccount = imessagePlugin.status?.probeAccount;
|
||||
if (!probeAccount) {
|
||||
throw new Error("imessage status.probeAccount unavailable");
|
||||
}
|
||||
|
||||
const probeSpy = vi.spyOn(channelRuntimeModule, "probeIMessageAccount").mockResolvedValue({
|
||||
ok: true,
|
||||
cliPath: "imsg-work",
|
||||
dbPath: "/tmp/work-db",
|
||||
} as Awaited<ReturnType<typeof channelRuntimeModule.probeIMessageAccount>>);
|
||||
|
||||
const cfg = {
|
||||
channels: {
|
||||
imessage: {
|
||||
cliPath: "imsg-root",
|
||||
dbPath: "/tmp/root-db",
|
||||
accounts: {
|
||||
work: {
|
||||
cliPath: "imsg-work",
|
||||
dbPath: "/tmp/work-db",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
const account = imessagePlugin.config.resolveAccount(cfg, "work");
|
||||
|
||||
await probeAccount({ account, cfg, timeoutMs: 2500 } as never);
|
||||
|
||||
expect(probeSpy).toHaveBeenCalledWith({
|
||||
timeoutMs: 2500,
|
||||
cliPath: "imsg-work",
|
||||
dbPath: "/tmp/work-db",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user