mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 04:31:10 +00:00
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import type { OpenClawConfig } from "../runtime-api.js";
|
|
import { fetchGraphJson, resolveGraphToken } from "./graph.js";
|
|
|
|
type GraphUserProfile = {
|
|
id?: string;
|
|
displayName?: string;
|
|
mail?: string;
|
|
jobTitle?: string;
|
|
userPrincipalName?: string;
|
|
officeLocation?: string;
|
|
};
|
|
|
|
export type GetMemberInfoMSTeamsParams = {
|
|
cfg: OpenClawConfig;
|
|
userId: string;
|
|
};
|
|
|
|
export type GetMemberInfoMSTeamsResult = {
|
|
user: {
|
|
id: string | undefined;
|
|
displayName: string | undefined;
|
|
mail: string | undefined;
|
|
jobTitle: string | undefined;
|
|
userPrincipalName: string | undefined;
|
|
officeLocation: string | undefined;
|
|
};
|
|
};
|
|
|
|
/**
|
|
* Fetch a user profile from Microsoft Graph by user ID.
|
|
*/
|
|
export async function getMemberInfoMSTeams(
|
|
params: GetMemberInfoMSTeamsParams,
|
|
): Promise<GetMemberInfoMSTeamsResult> {
|
|
const token = await resolveGraphToken(params.cfg);
|
|
const path = `/users/${encodeURIComponent(params.userId)}?$select=id,displayName,mail,jobTitle,userPrincipalName,officeLocation`;
|
|
const user = await fetchGraphJson<GraphUserProfile>({ token, path });
|
|
return {
|
|
user: {
|
|
id: user.id,
|
|
displayName: user.displayName,
|
|
mail: user.mail,
|
|
jobTitle: user.jobTitle,
|
|
userPrincipalName: user.userPrincipalName,
|
|
officeLocation: user.officeLocation,
|
|
},
|
|
};
|
|
}
|