mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-30 22:10:20 +00:00
fix: honor mattermost action discovery account config
This commit is contained in:
@@ -43,8 +43,8 @@ type MattermostSendTextParams = Parameters<MattermostSendText>[0];
|
||||
type MattermostSendMedia = NonNullable<NonNullable<typeof mattermostPlugin.outbound>["sendMedia"]>;
|
||||
type MattermostSendMediaParams = Parameters<MattermostSendMedia>[0];
|
||||
|
||||
function getDescribedActions(cfg: OpenClawConfig): string[] {
|
||||
return [...(mattermostPlugin.actions?.describeMessageTool?.({ cfg })?.actions ?? [])];
|
||||
function getDescribedActions(cfg: OpenClawConfig, accountId?: string): string[] {
|
||||
return [...(mattermostPlugin.actions?.describeMessageTool?.({ cfg, accountId })?.actions ?? [])];
|
||||
}
|
||||
|
||||
function requireMattermostNormalizeTarget() {
|
||||
@@ -292,6 +292,34 @@ describe("mattermostPlugin", () => {
|
||||
expect(actions).toContain("react");
|
||||
});
|
||||
|
||||
it("honors the selected Mattermost account during discovery", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: {
|
||||
mattermost: {
|
||||
enabled: true,
|
||||
actions: { reactions: false },
|
||||
accounts: {
|
||||
default: {
|
||||
enabled: true,
|
||||
botToken: "test-token",
|
||||
baseUrl: "https://chat.example.com",
|
||||
actions: { reactions: false },
|
||||
},
|
||||
work: {
|
||||
enabled: true,
|
||||
botToken: "work-token",
|
||||
baseUrl: "https://chat.example.com",
|
||||
actions: { reactions: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(getDescribedActions(cfg, "default")).toEqual(["send"]);
|
||||
expect(getDescribedActions(cfg, "work")).toEqual(["send", "react"]);
|
||||
});
|
||||
|
||||
it("blocks react when default account disables reactions and accountId is omitted", async () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: {
|
||||
|
||||
@@ -69,11 +69,17 @@ const mattermostSecurityAdapter = createRestrictSendersChannelSecurity<ResolvedM
|
||||
|
||||
function describeMattermostMessageTool({
|
||||
cfg,
|
||||
accountId,
|
||||
}: Parameters<
|
||||
NonNullable<ChannelMessageActionAdapter["describeMessageTool"]>
|
||||
>[0]): ChannelMessageToolDiscovery {
|
||||
const enabledAccounts = listMattermostAccountIds(cfg)
|
||||
.map((accountId) => resolveMattermostAccount({ cfg, accountId }))
|
||||
const enabledAccounts = (
|
||||
accountId
|
||||
? [resolveMattermostAccount({ cfg, accountId })]
|
||||
: listMattermostAccountIds(cfg).map((listedAccountId) =>
|
||||
resolveMattermostAccount({ cfg, accountId: listedAccountId }),
|
||||
)
|
||||
)
|
||||
.filter((account) => account.enabled)
|
||||
.filter((account) => Boolean(account.botToken?.trim() && account.baseUrl?.trim()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user