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

Function filterEmailsByLabels

apps/sim/lib/webhooks/polling/gmail.ts:425–437  ·  view source on GitHub ↗
(emails: GmailEmail[], config: GmailWebhookConfig)

Source from the content-addressed store, hash-verified

423}
424
425function filterEmailsByLabels(emails: GmailEmail[], config: GmailWebhookConfig): GmailEmail[] {
426 if (!config.labelIds.length) {
427 return emails
428 }
429
430 return emails.filter((email) => {
431 const emailLabels = email.labelIds || []
432 const hasMatchingLabel = config.labelIds.some((configLabel) =>
433 emailLabels.includes(configLabel)
434 )
435 return config.labelFilterBehavior === 'INCLUDE' ? hasMatchingLabel : !hasMatchingLabel
436 })
437}
438
439async function processEmails(
440 emails: GmailEmail[],

Callers 1

fetchNewEmailsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected