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

Function getGmailProfileHistoryId

apps/sim/lib/webhooks/polling/gmail.ts:385–406  ·  view source on GitHub ↗
(
  accessToken: string,
  requestId: string,
  logger: Logger
)

Source from the content-addressed store, hash-verified

383}
384
385async function getGmailProfileHistoryId(
386 accessToken: string,
387 requestId: string,
388 logger: Logger
389): Promise<string | null> {
390 try {
391 const response = await fetch('https://gmail.googleapis.com/gmail/v1/users/me/profile', {
392 headers: { Authorization: `Bearer ${accessToken}` },
393 })
394 if (!response.ok) {
395 logger.warn(
396 `[${requestId}] Failed to fetch Gmail profile for fresh historyId: ${response.status}`
397 )
398 return null
399 }
400 const profile = await response.json()
401 return (profile.historyId as string | undefined) ?? null
402 } catch (error) {
403 logger.warn(`[${requestId}] Error fetching Gmail profile:`, error)
404 return null
405 }
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`

Callers 1

fetchNewEmailsFunction · 0.85

Calls 1

warnMethod · 0.65

Tested by

no test coverage detected