allow text to be nullable (#142)

This commit is contained in:
KM Koushik
2025-03-31 23:25:03 +11:00
committed by GitHub
parent d107d59dfd
commit d0780290b0
2 changed files with 17 additions and 14 deletions

View File

@@ -99,6 +99,13 @@ export async function sendEmail(
}
}
if (!text && !html) {
throw new UnsendApiError({
code: "BAD_REQUEST",
message: "Either text or html is required",
});
}
const scheduledAtDate = scheduledAt ? new Date(scheduledAt) : undefined;
const delay = scheduledAtDate
? Math.max(0, scheduledAtDate.getTime() - Date.now())