mirror of https://github.com/openclaw/openclaw.git
fix(regression): preserve googlechat pairing account context
This commit is contained in:
parent
286d6b388f
commit
d69664e107
|
|
@ -290,6 +290,51 @@ describe("googlechatPlugin outbound resolveTarget", () => {
|
|||
});
|
||||
|
||||
describe("googlechatPlugin outbound cfg threading", () => {
|
||||
it("preserves accountId when sending pairing approvals", async () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
googlechat: {
|
||||
enabled: true,
|
||||
accounts: {
|
||||
work: {
|
||||
serviceAccount: {
|
||||
type: "service_account",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const account = {
|
||||
accountId: "work",
|
||||
config: {},
|
||||
credentialSource: "inline",
|
||||
};
|
||||
resolveGoogleChatAccountMock.mockReturnValue(account);
|
||||
resolveGoogleChatOutboundSpaceMock.mockResolvedValue("spaces/WORK");
|
||||
sendGoogleChatMessageMock.mockResolvedValue({
|
||||
messageName: "spaces/WORK/messages/msg-1",
|
||||
});
|
||||
|
||||
await googlechatPlugin.pairing?.notifyApproval?.({
|
||||
cfg: cfg as never,
|
||||
id: "user@example.com",
|
||||
accountId: "work",
|
||||
});
|
||||
|
||||
expect(resolveGoogleChatAccountMock).toHaveBeenCalledWith({
|
||||
cfg,
|
||||
accountId: "work",
|
||||
});
|
||||
expect(sendGoogleChatMessageMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
account,
|
||||
space: "spaces/WORK",
|
||||
text: expect.any(String),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("threads resolved cfg into sendText account resolution", async () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
|
|
|
|||
|
|
@ -317,8 +317,8 @@ export const googlechatPlugin = createChatChannelPlugin({
|
|||
idLabel: "googlechatUserId",
|
||||
message: PAIRING_APPROVED_MESSAGE,
|
||||
normalizeAllowEntry: (entry) => formatAllowFromEntry(entry),
|
||||
notify: async ({ cfg, id, message }) => {
|
||||
const account = resolveGoogleChatAccount({ cfg: cfg });
|
||||
notify: async ({ cfg, id, message, accountId }) => {
|
||||
const account = resolveGoogleChatAccount({ cfg: cfg, accountId });
|
||||
if (account.credentialSource === "none") {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue