Openstatus www.openstatus.dev

fix: email monitor alert (#1607)

authored by

Maximilian Kaske and committed by
GitHub
a9288d6c 7a5fceb8

+32 -2
+29
packages/emails/hotfix/monitor-alert.ts
··· 1 + interface MonitorAlertEmailProps { 2 + name?: string; 3 + type: "alert" | "degraded" | "recovery"; 4 + url?: string; 5 + status?: string; 6 + latency?: string; 7 + region?: string; 8 + timestamp?: string; 9 + message?: string; 10 + } 11 + 12 + export function monitorAlertEmail(props: MonitorAlertEmailProps) { 13 + return ` 14 + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 15 + <html dir="ltr" lang="en"> 16 + <body> 17 + <p>Your monitor is ${props.type}</p> 18 + <ul> 19 + <li>URL: ${props.url || "N/A"}</li> 20 + <li>Status: ${props.status || "N/A"}</li> 21 + <li>Latency: ${props.latency || "N/A"}</li> 22 + <li>Region: ${props.region || "N/A"}</li> 23 + <li>Timestamp: ${props.timestamp || "N/A"}</li> 24 + <li>Message: ${props.message || "N/A"}</li> 25 + </ul> 26 + </body> 27 + </html> 28 + `; 29 + }
+3 -2
packages/emails/src/client.tsx
··· 3 3 import { render } from "@react-email/render"; 4 4 import { Resend } from "resend"; 5 5 import FollowUpEmail from "../emails/followup"; 6 - import MonitorAlertEmail from "../emails/monitor-alert"; 7 6 import type { MonitorAlertProps } from "../emails/monitor-alert"; 8 7 import PageSubscriptionEmail from "../emails/page-subscription"; 9 8 import type { PageSubscriptionProps } from "../emails/page-subscription"; ··· 11 10 import type { StatusReportProps } from "../emails/status-report"; 12 11 import TeamInvitationEmail from "../emails/team-invitation"; 13 12 import type { TeamInvitationProps } from "../emails/team-invitation"; 13 + import { monitorAlertEmail } from "../hotfix/monitor-alert"; 14 14 15 15 // split an array into chunks of a given size. 16 16 function chunk<T>(array: T[], size: number): T[][] { ··· 164 164 } 165 165 166 166 try { 167 - const html = await render(<MonitorAlertEmail {...req} />); 167 + // const html = await render(<MonitorAlertEmail {...req} />); 168 + const html = monitorAlertEmail(req); 168 169 const result = await this.client.emails.send({ 169 170 from: "OpenStatus <notifications@notifications.openstatus.dev>", 170 171 subject: `${req.name}: ${req.type.toUpperCase()}`,