( recipientEmail: string, emailType: EmailType, html?: string, text?: string )
| 14 | } |
| 15 | |
| 16 | function buildUnsubscribeInjection( |
| 17 | recipientEmail: string, |
| 18 | emailType: EmailType, |
| 19 | html?: string, |
| 20 | text?: string |
| 21 | ): UnsubscribeInjection { |
| 22 | const token = generateUnsubscribeToken(recipientEmail, emailType) |
| 23 | const baseUrl = getBaseUrl() |
| 24 | const encodedEmail = encodeURIComponent(recipientEmail) |
| 25 | const unsubscribeUrl = `${baseUrl}/unsubscribe?token=${token}&email=${encodedEmail}` |
| 26 | |
| 27 | return { |
| 28 | headers: { |
| 29 | 'List-Unsubscribe': `<${unsubscribeUrl}>`, |
| 30 | 'List-Unsubscribe-Post': 'List-Unsubscribe=One-Click', |
| 31 | }, |
| 32 | html: html |
| 33 | ?.replace(/\{\{UNSUBSCRIBE_TOKEN\}\}/g, token) |
| 34 | .replace(/\{\{UNSUBSCRIBE_EMAIL\}\}/g, encodedEmail), |
| 35 | text: text |
| 36 | ?.replace(/\{\{UNSUBSCRIBE_TOKEN\}\}/g, token) |
| 37 | .replace(/\{\{UNSUBSCRIBE_EMAIL\}\}/g, encodedEmail), |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | function validateAndSanitize(options: EmailOptions): { |
| 42 | senderEmail: string |
no test coverage detected