MCPcopy Index your code
hub / github.com/simstudioai/sim / fetchThread

Function fetchThread

apps/sim/connectors/gmail/gmail.ts:257–274  ·  view source on GitHub ↗

* Fetches a full thread with all its messages.

(accessToken: string, threadId: string)

Source from the content-addressed store, hash-verified

255 * Fetches a full thread with all its messages.
256 */
257async function fetchThread(accessToken: string, threadId: string): Promise<GmailThread | null> {
258 const url = `${GMAIL_API_BASE}/threads/${threadId}?format=FULL`
259
260 const response = await fetchWithRetry(url, {
261 method: 'GET',
262 headers: {
263 Authorization: `Bearer ${accessToken}`,
264 Accept: 'application/json',
265 },
266 })
267
268 if (!response.ok) {
269 if (response.status === 404) return null
270 throw new Error(`Failed to fetch thread ${threadId}: ${response.status}`)
271 }
272
273 return (await response.json()) as GmailThread
274}
275
276/**
277 * Resolves label IDs to human-readable label names using a cache.

Callers 1

gmail.tsFile · 0.85

Calls 1

fetchWithRetryFunction · 0.90

Tested by

no test coverage detected