|
|
|
|
@ -1,4 +1,8 @@
|
|
|
|
|
import { mapAllowlistResolutionInputs } from "openclaw/plugin-sdk/allow-from";
|
|
|
|
|
import {
|
|
|
|
|
normalizeLowercaseStringOrEmpty,
|
|
|
|
|
normalizeOptionalLowercaseString,
|
|
|
|
|
} from "openclaw/plugin-sdk/text-runtime";
|
|
|
|
|
import { searchGraphUsers } from "./graph-users.js";
|
|
|
|
|
import {
|
|
|
|
|
listChannelsForTeam,
|
|
|
|
|
@ -135,7 +139,9 @@ export async function resolveMSTeamsChannelAllowlist(params: {
|
|
|
|
|
} catch {
|
|
|
|
|
// API failure (rate limit, network error) — fall back to Graph GUID as team key
|
|
|
|
|
}
|
|
|
|
|
const generalChannel = teamChannels.find((ch) => ch.displayName?.toLowerCase() === "general");
|
|
|
|
|
const generalChannel = teamChannels.find(
|
|
|
|
|
(ch) => normalizeOptionalLowercaseString(ch.displayName) === "general",
|
|
|
|
|
);
|
|
|
|
|
// Use the General channel's conversation ID as the team key — this
|
|
|
|
|
// matches what Bot Framework sends at runtime. Fall back to the Graph
|
|
|
|
|
// GUID if the General channel isn't found (renamed or deleted).
|
|
|
|
|
@ -150,11 +156,14 @@ export async function resolveMSTeamsChannelAllowlist(params: {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
// Reuse teamChannels — already fetched above
|
|
|
|
|
const normalizedChannel = normalizeOptionalLowercaseString(channel);
|
|
|
|
|
const channelMatch =
|
|
|
|
|
teamChannels.find((item) => item.id === channel) ??
|
|
|
|
|
teamChannels.find((item) => item.displayName?.toLowerCase() === channel.toLowerCase()) ??
|
|
|
|
|
teamChannels.find(
|
|
|
|
|
(item) => normalizeOptionalLowercaseString(item.displayName) === normalizedChannel,
|
|
|
|
|
) ??
|
|
|
|
|
teamChannels.find((item) =>
|
|
|
|
|
item.displayName?.toLowerCase().includes(channel.toLowerCase() ?? ""),
|
|
|
|
|
normalizeLowercaseStringOrEmpty(item.displayName ?? "").includes(normalizedChannel ?? ""),
|
|
|
|
|
);
|
|
|
|
|
if (!channelMatch?.id) {
|
|
|
|
|
return { input, resolved: false, note: "channel not found" };
|
|
|
|
|
|