(raw: RawEmail)
| 59 | } |
| 60 | |
| 61 | export async function parseRawEmail(raw: RawEmail): Promise<ParsedInboundEmail> { |
| 62 | const email = await PostalMime.parse(raw); |
| 63 | |
| 64 | return { |
| 65 | messageId: email.messageId?.trim() ?? null, |
| 66 | from: firstAddress(email.from), |
| 67 | subject: email.subject ?? '', |
| 68 | text: normalizeText(email.text, email.html), |
| 69 | }; |
| 70 | } |
| 71 | |
| 72 | function rawBytes(raw: string | ArrayBuffer | Uint8Array): Uint8Array { |
| 73 | if (typeof raw === 'string') return new TextEncoder().encode(raw); |
no test coverage detected