fix(regression): preserve googlechat pairing account context

This commit is contained in:
Tak Hoffman 2026-03-27 23:24:50 -05:00
parent 286d6b388f
commit d69664e107
No known key found for this signature in database
2 changed files with 47 additions and 2 deletions

View File

@ -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: {

View File

@ -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;
}