MCPcopy Index your code
hub / github.com/CopilotKit/CopilotKit / getMessageFileRefs

Function getMessageFileRefs

packages/bot-teams/src/graph-files.ts:103–133  ·  view source on GitHub ↗

Read a channel message and return its file-reference attachments.

(
  ref: ChannelMessageRef,
  token: string,
)

Source from the content-addressed store, hash-verified

101
102/** Read a channel message and return its file-reference attachments. */
103async function getMessageFileRefs(
104 ref: ChannelMessageRef,
105 token: string,
106): Promise<GraphFileRef[]> {
107 const channel = encodeURIComponent(ref.channelId);
108 const url =
109 ref.rootId && ref.rootId !== ref.messageId
110 ? `${GRAPH}/teams/${ref.teamId}/channels/${channel}/messages/${ref.rootId}/replies/${ref.messageId}`
111 : `${GRAPH}/teams/${ref.teamId}/channels/${channel}/messages/${ref.messageId}`;
112 const res = await fetch(url, {
113 headers: { Authorization: `Bearer ${token}` },
114 });
115 if (!res.ok) {
116 throw new Error(
117 `read channel message failed (HTTP ${res.status}): ${(await res.text()).slice(0, 200)}`,
118 );
119 }
120 const msg = (await res.json()) as {
121 attachments?: Array<{
122 contentType?: string;
123 contentUrl?: string;
124 name?: string;
125 }>;
126 };
127 return (msg.attachments ?? [])
128 .filter(
129 (a): a is { contentType: string; contentUrl: string; name?: string } =>
130 a.contentType === "reference" && typeof a.contentUrl === "string",
131 )
132 .map((a) => ({ name: a.name ?? "file", contentUrl: a.contentUrl }));
133}
134
135/** Download a SharePoint file by its sharing URL via the Graph `/shares` API. */
136async function downloadSharedFile(

Callers 1

Calls 4

fetchFunction · 0.85
textMethod · 0.80
filterMethod · 0.80
jsonMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…