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

Function markEmailAsRead

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

Source from the content-addressed store, hash-verified

575}
576
577async function markEmailAsRead(accessToken: string, messageId: string, logger: Logger) {
578 const modifyUrl = `https://gmail.googleapis.com/gmail/v1/users/me/messages/${messageId}/modify`
579
580 try {
581 const response = await fetch(modifyUrl, {
582 method: 'POST',
583 headers: {
584 Authorization: `Bearer ${accessToken}`,
585 'Content-Type': 'application/json',
586 },
587 body: JSON.stringify({ removeLabelIds: ['UNREAD'] }),
588 })
589
590 if (!response.ok) {
591 await response.body?.cancel().catch(() => {})
592 throw new Error(
593 `Failed to mark email ${messageId} as read: ${response.status} ${response.statusText}`
594 )
595 }
596 } catch (error) {
597 logger.error(`Error marking email ${messageId} as read:`, error)
598 throw error
599 }
600}

Callers 1

processEmailsFunction · 0.85

Calls 2

cancelMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected