Skip to content

Commit 731fe8f

Browse files
committed
fix(qqbot): reject disabled channel API accounts
1 parent 097c9f8 commit 731fe8f

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎extensions/qqbot/src/bridge/tools/channel.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,32 @@ describe("bridge/tools/channel", () => {
130130
expect(getAccessTokenMock).not.toHaveBeenCalled();
131131
});
132132

133+
it("does not expose the tool when the active account is disabled", () => {
134+
const disabledAccount = {
135+
...cfg,
136+
channels: {
137+
qqbot: {
138+
...cfg.channels?.qqbot,
139+
accounts: {
140+
bot2: {
141+
...cfg.channels?.qqbot?.accounts?.bot2,
142+
enabled: false,
143+
},
144+
},
145+
},
146+
},
147+
} as OpenClawConfig;
148+
149+
expect(
150+
registerToolFactory(disabledAccount)({
151+
messageChannel: "qqbot",
152+
agentAccountId: "bot2",
153+
}),
154+
).toBeNull();
155+
expect(getAccessTokenMock).not.toHaveBeenCalled();
156+
expect(fetchWithSsrFGuardMock).not.toHaveBeenCalled();
157+
});
158+
133159
it("does not treat another channel's account ID as a QQBot account", async () => {
134160
const tool = registerToolFactory()({ messageChannel: "discord", agentAccountId: "bot2" });
135161
expect(tool).not.toBeNull();

‎extensions/qqbot/src/bridge/tools/channel.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function createChannelTool(
2929
? (context.agentAccountId ?? context.deliveryContext?.accountId)
3030
: undefined,
3131
);
32-
if (!account.appId || !account.clientSecret) {
32+
if (!account.enabled || !account.appId || !account.clientSecret) {
3333
return null;
3434
}
3535

0 commit comments

Comments
 (0)