Skip to content

Commit 7c3af37

Browse files
authored
msteams: extend MSTeamsAdapter and MSTeamsActivityHandler types; implement self() (openclaw#49929)
- Add updateActivity/deleteActivity to MSTeamsAdapter - Add onReactionsAdded/onReactionsRemoved to MSTeamsActivityHandler - Implement directory self() to return bot identity from appId credential - Add tests for self() in channel.directory.test.ts
1 parent 897cda7 commit 7c3af37

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

extensions/msteams/src/channel.directory.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@ import { msteamsPlugin } from "./channel.js";
99
describe("msteams directory", () => {
1010
const runtimeEnv = createDirectoryTestRuntime() as RuntimeEnv;
1111

12+
describe("self()", () => {
13+
it("returns bot identity when credentials are configured", async () => {
14+
const cfg = {
15+
channels: {
16+
msteams: {
17+
appId: "test-app-id-1234",
18+
appPassword: "secret",
19+
tenantId: "tenant-id-5678",
20+
},
21+
},
22+
} as unknown as OpenClawConfig;
23+
24+
const result = await msteamsPlugin.directory?.self?.({ cfg, runtime: runtimeEnv });
25+
expect(result).toEqual({ kind: "user", id: "test-app-id-1234", name: "test-app-id-1234" });
26+
});
27+
28+
it("returns null when credentials are not configured", async () => {
29+
const cfg = { channels: {} } as unknown as OpenClawConfig;
30+
const result = await msteamsPlugin.directory?.self?.({ cfg, runtime: runtimeEnv });
31+
expect(result).toBeNull();
32+
});
33+
});
34+
1235
it("lists peers and groups from config", async () => {
1336
const cfg = {
1437
channels: {

extensions/msteams/src/channel.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ export const msteamsPlugin: ChannelPlugin<ResolvedMSTeamsAccount> = {
217217
},
218218
},
219219
directory: createChannelDirectoryAdapter({
220+
self: async ({ cfg }) => {
221+
const creds = resolveMSTeamsCredentials(cfg.channels?.msteams);
222+
if (!creds) {
223+
return null;
224+
}
225+
return { kind: "user" as const, id: creds.appId, name: creds.appId };
226+
},
220227
listPeers: async ({ cfg, query, limit }) =>
221228
listDirectoryEntriesFromSources({
222229
kind: "user",

extensions/msteams/src/messenger.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export type MSTeamsAdapter = {
6161
res: unknown,
6262
logic: (context: unknown) => Promise<void>,
6363
) => Promise<void>;
64+
updateActivity: (context: unknown, activity: object) => Promise<void>;
65+
deleteActivity: (context: unknown, reference: { activityId?: string }) => Promise<void>;
6466
};
6567

6668
export type MSTeamsReplyRenderOptions = {

extensions/msteams/src/monitor-handler.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ export type MSTeamsActivityHandler = {
2121
onMembersAdded: (
2222
handler: (context: unknown, next: () => Promise<void>) => Promise<void>,
2323
) => MSTeamsActivityHandler;
24+
onReactionsAdded: (
25+
handler: (context: unknown, next: () => Promise<void>) => Promise<void>,
26+
) => MSTeamsActivityHandler;
27+
onReactionsRemoved: (
28+
handler: (context: unknown, next: () => Promise<void>) => Promise<void>,
29+
) => MSTeamsActivityHandler;
2430
run?: (context: unknown) => Promise<void>;
2531
};
2632

0 commit comments

Comments
 (0)