mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 12:30:44 +00:00
fix(qqbot): preserve framework command authorization (#77453)
* fix(qqbot): preserve framework command authorization * Add changelog entry for PR #77453
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
|
||||
import type { PluginCommandContext } from "openclaw/plugin-sdk/plugin-entry";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildFrameworkSlashContext } from "./framework-context-adapter.js";
|
||||
|
||||
function createCommandContext(isAuthorizedSender: boolean): PluginCommandContext {
|
||||
return {
|
||||
senderId: "SENDER_OPENID",
|
||||
channel: "qqbot",
|
||||
isAuthorizedSender,
|
||||
args: "on",
|
||||
commandBody: "/bot-streaming on",
|
||||
config: {} as OpenClawConfig,
|
||||
from: "qqbot:c2c:SENDER_OPENID",
|
||||
requestConversationBinding: async () => undefined,
|
||||
detachConversationBinding: async () => ({ removed: false }),
|
||||
getCurrentConversationBinding: async () => null,
|
||||
} as unknown as PluginCommandContext;
|
||||
}
|
||||
|
||||
describe("buildFrameworkSlashContext", () => {
|
||||
it("preserves the framework authorization decision in the slash context", () => {
|
||||
const authorized = buildFrameworkSlashContext({
|
||||
ctx: createCommandContext(true),
|
||||
account: {
|
||||
accountId: "default",
|
||||
enabled: true,
|
||||
appId: "app",
|
||||
clientSecret: "secret",
|
||||
secretSource: "config",
|
||||
markdownSupport: true,
|
||||
config: {},
|
||||
},
|
||||
from: { msgType: "c2c", targetType: "c2c", targetId: "SENDER_OPENID" },
|
||||
commandName: "bot-streaming",
|
||||
});
|
||||
const unauthorized = buildFrameworkSlashContext({
|
||||
ctx: createCommandContext(false),
|
||||
account: {
|
||||
accountId: "default",
|
||||
enabled: true,
|
||||
appId: "app",
|
||||
clientSecret: "secret",
|
||||
secretSource: "config",
|
||||
markdownSupport: true,
|
||||
config: {},
|
||||
},
|
||||
from: { msgType: "c2c", targetType: "c2c", targetId: "SENDER_OPENID" },
|
||||
commandName: "bot-streaming",
|
||||
});
|
||||
|
||||
expect(authorized.commandAuthorized).toBe(true);
|
||||
expect(unauthorized.commandAuthorized).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -54,7 +54,7 @@ export function buildFrameworkSlashContext({
|
||||
accountId: account.accountId,
|
||||
appId: account.appId,
|
||||
accountConfig: account.config as unknown as Record<string, unknown>,
|
||||
commandAuthorized: true,
|
||||
commandAuthorized: ctx.isAuthorizedSender,
|
||||
queueSnapshot: { ...DEFAULT_QUEUE_SNAPSHOT },
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user