(threads: SerializedThread[])
| 11 | }; |
| 12 | |
| 13 | export function getImageUrls(threads: SerializedThread[]): string[] { |
| 14 | const array = threads.map((thread) => { |
| 15 | const { messages } = thread; |
| 16 | return messages |
| 17 | .map((message) => { |
| 18 | const parser = parsers[message.messageFormat]; |
| 19 | const tree = parser(message.body); |
| 20 | const urls = find.urls(tree); |
| 21 | return [ |
| 22 | ...urls, |
| 23 | ...message.attachments.map((attachment) => attachment.url), |
| 24 | ].filter(isImage); |
| 25 | }) |
| 26 | .flat(); |
| 27 | }); |
| 28 | |
| 29 | return unique(array.flat()); |
| 30 | } |