| 466 | } |
| 467 | |
| 468 | function hasAttachmentsInBodyStructure(structure: FetchMessageObject['bodyStructure']): boolean { |
| 469 | if (!structure) return false |
| 470 | if (structure.disposition === 'attachment') return true |
| 471 | if (structure.disposition === 'inline' && structure.dispositionParameters?.filename) return true |
| 472 | if (structure.childNodes && Array.isArray(structure.childNodes)) { |
| 473 | return structure.childNodes.some((child) => hasAttachmentsInBodyStructure(child)) |
| 474 | } |
| 475 | return false |
| 476 | } |
| 477 | |
| 478 | async function processEmails( |
| 479 | emails: Array<{ |