* Gets a header value from a Gmail message payload.
(payload: GmailMessagePart | undefined, name: string)
| 187 | * Gets a header value from a Gmail message payload. |
| 188 | */ |
| 189 | function getHeader(payload: GmailMessagePart | undefined, name: string): string | undefined { |
| 190 | if (!payload?.headers) return undefined |
| 191 | const header = payload.headers.find((h) => h.name.toLowerCase() === name.toLowerCase()) |
| 192 | return header?.value |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Formats a thread's messages into a single document string. |