;
}) {
+ const resolvedEventId = await resolveEventId(input.eventId);
+ if (!resolvedEventId) {
+ throw new ApiError(404, "No certificate template exists for this event");
+ }
+
const template = await prisma.certificate.findFirst({
- where: { eventId: input.eventId },
+ where: { eventId: resolvedEventId },
});
if (!template) {
throw new ApiError(404, "No certificate template exists for this event");
@@ -134,8 +207,9 @@ export async function sendCertificateEmail(input: {
name: string;
eventName: string;
certificateId: string;
+ isTest?: boolean;
}) {
- const verifyUrl = `${siteUrl()}/verify/certificate?certificateId=${encodeURIComponent(input.certificateId)}`;
+ const verifyUrl = `${siteUrl()}/verify/certificate?id=${encodeURIComponent(input.certificateId)}`;
const escape = (v: string) =>
v.replace(/&/g, "&").replace(//g, ">");
@@ -153,11 +227,12 @@ export async function sendCertificateEmail(input: {
Hi ${escape(input.name)}, thank you for taking part in
${escape(input.eventName)}. Your certificate is available below.
+${input.isTest ? `This is a test email. A certificate is not issued until you use Send Mail.
` : `
-Certificate ID: ${escape(input.certificateId)}
+Certificate ID: ${escape(input.certificateId)}
`}