|
1 | 1 | import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers"; |
2 | 2 | import { formatAllowFromLowercase } from "openclaw/plugin-sdk/allow-from"; |
| 3 | +import { createActionGate } from "openclaw/plugin-sdk/channel-actions"; |
3 | 4 | import { createTopLevelChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers"; |
4 | 5 | import type { |
5 | 6 | ChannelMessageActionAdapter, |
@@ -163,6 +164,15 @@ function jsonActionResultWithDetails( |
163 | 164 | } |
164 | 165 |
|
165 | 166 | const MSTEAMS_REACTION_TYPES = ["like", "heart", "laugh", "surprised", "sad", "angry"] as const; |
| 167 | +const MSTEAMS_MEMBER_INFO_DISABLED_ERROR = |
| 168 | + "member-info is disabled via channels.msteams.actions.memberInfo=false."; |
| 169 | + |
| 170 | +function isMSTeamsMemberInfoActionEnabled(cfg: OpenClawConfig): boolean { |
| 171 | + const gate = createActionGate( |
| 172 | + cfg.channels?.msteams?.actions as Record<string, boolean | undefined> | undefined, |
| 173 | + ); |
| 174 | + return gate("memberInfo"); |
| 175 | +} |
166 | 176 |
|
167 | 177 | function actionError(message: string) { |
168 | 178 | return { |
@@ -369,28 +379,28 @@ function describeMSTeamsMessageTool({ |
369 | 379 | const enabled = |
370 | 380 | cfg.channels?.msteams?.enabled !== false && |
371 | 381 | Boolean(resolveMSTeamsCredentials(cfg.channels?.msteams)); |
| 382 | + const actions: ChannelMessageActionName[] = [ |
| 383 | + "upload-file", |
| 384 | + "poll", |
| 385 | + "edit", |
| 386 | + "delete", |
| 387 | + "pin", |
| 388 | + "unpin", |
| 389 | + "list-pins", |
| 390 | + "read", |
| 391 | + "react", |
| 392 | + "reactions", |
| 393 | + "search", |
| 394 | + ...(isMSTeamsMemberInfoActionEnabled(cfg) ? (["member-info"] as const) : []), |
| 395 | + "channel-list", |
| 396 | + "channel-info", |
| 397 | + "addParticipant", |
| 398 | + "removeParticipant", |
| 399 | + "renameGroup", |
| 400 | + ]; |
| 401 | + |
372 | 402 | return { |
373 | | - actions: enabled |
374 | | - ? ([ |
375 | | - "upload-file", |
376 | | - "poll", |
377 | | - "edit", |
378 | | - "delete", |
379 | | - "pin", |
380 | | - "unpin", |
381 | | - "list-pins", |
382 | | - "read", |
383 | | - "react", |
384 | | - "reactions", |
385 | | - "search", |
386 | | - "member-info", |
387 | | - "channel-list", |
388 | | - "channel-info", |
389 | | - "addParticipant", |
390 | | - "removeParticipant", |
391 | | - "renameGroup", |
392 | | - ] satisfies ChannelMessageActionName[]) |
393 | | - : [], |
| 403 | + actions: enabled ? actions : [], |
394 | 404 | capabilities: enabled ? ["presentation"] : [], |
395 | 405 | schema: enabled |
396 | 406 | ? { |
@@ -966,6 +976,9 @@ export const msteamsPlugin: ChannelPlugin<ResolvedMSTeamsAccount, ProbeMSTeamsRe |
966 | 976 | } |
967 | 977 |
|
968 | 978 | if (ctx.action === "member-info") { |
| 979 | + if (!isMSTeamsMemberInfoActionEnabled(ctx.cfg)) { |
| 980 | + return actionError(MSTEAMS_MEMBER_INFO_DISABLED_ERROR); |
| 981 | + } |
969 | 982 | const userId = normalizeOptionalString(ctx.params.userId) ?? ""; |
970 | 983 | if (!userId) { |
971 | 984 | return actionError("member-info requires a userId."); |
|
0 commit comments