MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / fetchGraphMessages

Function fetchGraphMessages

microsoft-email.js:113–133  ·  view source on GitHub ↗
(accessToken, options = {})

Source from the content-addressed store, hash-verified

111 }
112
113 async function fetchGraphMessages(accessToken, options = {}) {
114 const fetchImpl = getFetchImpl(options.fetchImpl);
115 const mailbox = normalizeMailboxLabel(options.mailbox);
116 const top = Math.max(1, Math.min(Number(options.top) || 5, 30));
117 const url = `${GRAPH_API_BASE}/${normalizeMailboxId(mailbox)}/messages?$top=${encodeURIComponent(top)}&$select=id,internetMessageId,subject,from,bodyPreview,receivedDateTime&$orderby=receivedDateTime desc`;
118 const response = await fetchImpl(url, {
119 method: 'GET',
120 headers: {
121 Accept: 'application/json',
122 Authorization: `Bearer ${accessToken}`,
123 },
124 signal: options.signal,
125 });
126
127 if (!response.ok) {
128 throw new Error(`graph: ${await getResponseErrorText(response)}`);
129 }
130
131 const payload = await response.json();
132 return Array.isArray(payload?.value) ? payload.value : [];
133 }
134
135 async function fetchOutlookMessages(accessToken, options = {}) {
136 const fetchImpl = getFetchImpl(options.fetchImpl);

Callers 1

Calls 5

getFetchImplFunction · 0.85
normalizeMailboxLabelFunction · 0.85
normalizeMailboxIdFunction · 0.85
fetchImplFunction · 0.85
getResponseErrorTextFunction · 0.85

Tested by

no test coverage detected