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

Function filterEmailsByFolder

apps/sim/lib/webhooks/polling/outlook.ts:355–377  ·  view source on GitHub ↗
(
  emails: OutlookEmail[],
  config: OutlookWebhookConfig,
  resolvedFolderIds?: Map<string, string>
)

Source from the content-addressed store, hash-verified

353}
354
355function filterEmailsByFolder(
356 emails: OutlookEmail[],
357 config: OutlookWebhookConfig,
358 resolvedFolderIds?: Map<string, string>
359): OutlookEmail[] {
360 if (!config.folderIds || !config.folderIds.length) return emails
361
362 const actualFolderIds = config.folderIds.map((configFolder) => {
363 if (resolvedFolderIds && isWellKnownFolderName(configFolder)) {
364 const resolvedId = resolvedFolderIds.get(configFolder.toLowerCase())
365 if (resolvedId) return resolvedId
366 }
367 return configFolder
368 })
369
370 return emails.filter((email) => {
371 const emailFolderId = email.parentFolderId
372 const hasMatchingFolder = actualFolderIds.some(
373 (folderId) => emailFolderId.toLowerCase() === folderId.toLowerCase()
374 )
375 return config.folderFilterBehavior === 'INCLUDE' ? hasMatchingFolder : !hasMatchingFolder
376 })
377}
378
379async function processOutlookEmails(
380 emails: OutlookEmail[],

Callers 1

fetchNewOutlookEmailsFunction · 0.85

Calls 2

isWellKnownFolderNameFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected