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

Function getEmailDetails

apps/sim/lib/webhooks/polling/gmail.ts:408–423  ·  view source on GitHub ↗
(accessToken: string, messageId: string)

Source from the content-addressed store, hash-verified

406}
407
408async function getEmailDetails(accessToken: string, messageId: string): Promise<GmailEmail> {
409 const messageUrl = `https://gmail.googleapis.com/gmail/v1/users/me/messages/${messageId}?format=full`
410
411 const messageResponse = await fetch(messageUrl, {
412 headers: { Authorization: `Bearer ${accessToken}` },
413 })
414
415 if (!messageResponse.ok) {
416 const errorData = await messageResponse.json().catch(() => ({}))
417 throw new Error(
418 `Failed to fetch email details for message ${messageId}: ${messageResponse.status} ${messageResponse.statusText} - ${JSON.stringify(errorData)}`
419 )
420 }
421
422 return await messageResponse.json()
423}
424
425function filterEmailsByLabels(emails: GmailEmail[], config: GmailWebhookConfig): GmailEmail[] {
426 if (!config.labelIds.length) {

Callers 2

fetchNewEmailsFunction · 0.85
searchEmailsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected