// The team ID in channelData is typically the group ID itself for standard teams. // Validate by fetching /teams/{id} and returning the confirmed id. // Requires Team.ReadBasic.All permission; fall back to raw ID if missing. try { const path = `/teams/${encodeURIComponent(conversationTeamId)}?$select=id`; const team = await fetchGraphJson<{ id?: string }>({ token, path }); const groupId = team.id ?? conversationTeamId;
// Only cache when the Graph lookup succeeds — caching a fallback raw ID // can cause silent failures for the entire TTL if the ID is not a valid // Graph team GUID (e.g. Bot Framework conversation key).
teamGroupIdCache.set(conversationTeamId, {
groupId,
expiresAt: Date.now() + CACHE_TTL_MS,
});
return groupId;
} catch { // Fallback to raw team ID without caching so subsequent calls retry the // Graph lookup instead of using a potentially invalid cached value. return conversationTeamId;
}
}
/** *Fetchthreadrepliesforachannelmessage,orderedchronologically. * ***Limitation:**TheGraphAPIrepliesendpoint(`/messages/{id}/replies`)doesnot *support`$orderby`,soresultsarealwaysreturnedinascending(oldest-first)order. *Combinedwiththe`$top`capof50,thismeansonlythe**oldest50replies**are *returnedforlongthreads—newerrepliesaresilentlyomitted.Thereiscurrentlyno *GraphAPIworkaroundforthis;paginationvia`@odata.nextLink`canretrievemore *repliesbutstillinascendingorderonly.
*/
export async function fetchThreadReplies(
token: string,
groupId: string,
channelId: string,
messageId: string,
limit = 50,
): Promise<GraphThreadMessage[]> { const top = Math.min(Math.max(limit, 1), 50); // NOTE: Graph replies endpoint returns oldest-first and does not support $orderby. // For threads with >50 replies, only the oldest 50 are returned. The most recent // replies (often the most relevant context) may be truncated. const path = `/teams/${encodeURIComponent(groupId)}/channels/${encodeURIComponent(channelId)}/messages/${encodeURIComponent(messageId)}/replies?$top=${top}&$select=id,from,body,createdDateTime`; const res = await fetchGraphJson<GraphResponse<GraphThreadMessage>>({ token, path }); return res.value ?? [];
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.